diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts new file mode 100644 index 000000000..930562ce0 --- /dev/null +++ b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts @@ -0,0 +1,61 @@ +import {TestBed, getTestBed} from '@angular/core/testing'; +import { + HttpClientTestingModule, + HttpTestingController +} from '@angular/common/http/testing'; +import {NgRedux} from "@angular-redux/store"; +import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service"; +import {ActivatedRouteSnapshot, convertToParamMap} from "@angular/router"; +import {FlagsResolve} from "./flag.resolver"; +import {ConfigurationService} from "../../services/configuration.service"; + +class MockAppStore<T> { + getState() { + return { + service: { + serviceInstance: {} + } + } + } +} + + +describe('Flag resolver', () => { + let injector; + let resolver: FlagsResolve; + let configurationService: ConfigurationService; + let httpMock: HttpTestingController; + + let activatedRouteSnapshot: ActivatedRouteSnapshot; + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + FlagsResolve, + ConfigurationService, + FeatureFlagsService, + {provide: NgRedux, useClass: MockAppStore}, + { + provide: ActivatedRouteSnapshot, useValue: { + queryParamMap: + convertToParamMap({ }) + } + }, + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + resolver = injector.get(FlagsResolve); + httpMock = injector.get(HttpTestingController); + activatedRouteSnapshot = injector.get(ActivatedRouteSnapshot); + configurationService = injector.get(ConfigurationService); + + })().then(done).catch(done.fail)); + + test('should update flags', () => { + spyOn(configurationService, 'getFlags'); + resolver.resolve(activatedRouteSnapshot); + expect(configurationService.getFlags).toHaveBeenCalled(); + }); +}); |