summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/resolvers/flag
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/shared/resolvers/flag
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/resolvers/flag')
-rw-r--r--vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts61
-rw-r--r--vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.ts14
2 files changed, 75 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();
+ });
+});
diff --git a/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.ts b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.ts
new file mode 100644
index 000000000..7ebce8bde
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.ts
@@ -0,0 +1,14 @@
+import {ActivatedRouteSnapshot, Resolve} from "@angular/router";
+import {Injectable} from "@angular/core";
+import {Observable} from "rxjs";
+import {ConfigurationService} from "../../services/configuration.service";
+
+@Injectable()
+export class FlagsResolve implements Resolve<Observable< { [key: string]: boolean }>> {
+
+ constructor(private _configurationService: ConfigurationService) {}
+
+ resolve(route: ActivatedRouteSnapshot) {
+ return this._configurationService.getFlags();
+ }
+}