blob: 847af6676356366c363deea1c2b9a97612d463f2 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {FeatureFlagsService, Features} from "./feature-flags.service";
2import {getTestBed, TestBed} from "@angular/core/testing";
3import {NgRedux} from "@angular-redux/store";
4import each from 'jest-each';
5let flagValue:boolean;
6
7class MockReduxStore<T> {
8
9 getState() {
10 return {
11 "global": {
12 "flags": {
13 "FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST": flagValue,
14 },
15 },
16 }
17 };
18}
19
20describe('Feature flags Service', () => {
21
22 let injector;
23 let service: FeatureFlagsService;
24
25 beforeAll(done => (async () => {
26 TestBed.configureTestingModule({
27 providers: [
28 FeatureFlagsService,
29 {provide: NgRedux, useClass: MockReduxStore}]
30 });
31 await TestBed.compileComponents();
32
33 injector = getTestBed();
34 service = injector.get(FeatureFlagsService);
35
36 })().then(done).catch(done.fail));
37
38 let flagValueDataProvider = [
39 ['flag is true', true],
40 ['flag is false', false]
41 ];
42
43 each(flagValueDataProvider).test("should return the correct flag %s", (desc: string, flag: boolean) => {
44 flagValue = flag;
45 expect(service.getFlagState(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).toEqual(flag);
46 });
47});