fix(ui): fix falling tests
This commit is contained in:
parent
c1feac389f
commit
24b09458ce
4 changed files with 9 additions and 8 deletions
|
|
@ -122,9 +122,8 @@ export default class FeatureFlagsStore {
|
|||
if (this.currentFflag) {
|
||||
this.setLoading(true);
|
||||
try {
|
||||
// @ts-ignore
|
||||
const result = await this.client.createFlag(this.currentFflag.toJS());
|
||||
this.currentFflag.setHasChanged(false)
|
||||
const result = await this.client.createFlag(this.currentFflag.toJS());
|
||||
this.addFlag(new FeatureFlag(result));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@ type FFlagType = 'single' | 'multi';
|
|||
type FFlagCondition = {
|
||||
name: string;
|
||||
rolloutPercentage: number;
|
||||
filters: [];
|
||||
filters: any[];
|
||||
};
|
||||
|
||||
export interface SimpleFlag {
|
||||
name: string;
|
||||
flagKey: string;
|
||||
description: string;
|
||||
flagType: FFlagType;
|
||||
|
|
|
|||
|
|
@ -64,13 +64,13 @@ describe('Feature flag type test', () => {
|
|||
expect(featureFlag.payload).toBe('payload');
|
||||
|
||||
featureFlag.addVariant();
|
||||
expect(featureFlag.variants.length).toBe(2);
|
||||
expect(featureFlag.variants.length).toBe(3);
|
||||
|
||||
featureFlag.removeVariant(1);
|
||||
expect(featureFlag.variants.length).toBe(1);
|
||||
expect(featureFlag.variants.length).toBe(2);
|
||||
|
||||
featureFlag.redistributeVariants();
|
||||
expect(featureFlag.variants[0].rolloutPercentage).toBe(100);
|
||||
expect(featureFlag.variants[0].rolloutPercentage).toBe(50);
|
||||
|
||||
featureFlag.addCondition();
|
||||
expect(featureFlag.conditions.length).toBe(2);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ jest.mock('App/mstore/types/FeatureFlag', () => {
|
|||
constructor(data) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
setHasChanged() {
|
||||
return jest.fn(() => this)
|
||||
}
|
||||
|
||||
toJS() {
|
||||
return jest.fn(() => this)
|
||||
|
|
@ -48,7 +51,7 @@ describe('FeatureFlagsStore', () => {
|
|||
const mockFlag = { featureFlagId: 3 };
|
||||
mockFflagsService.createFlag.mockResolvedValueOnce(mockFlag);
|
||||
const store = new FeatureFlagsStore(mockFflagsService);
|
||||
store.currentFflag = new FeatureFlag();
|
||||
store.setCurrentFlag(new FeatureFlag())
|
||||
|
||||
await store.createFlag();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue