diff options
-rw-r--r-- | src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts b/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts index dc1d253..440993d 100644 --- a/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts +++ b/src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts @@ -27,7 +27,7 @@ import {CommonModule} from '@angular/common'; import 'rxjs/Rx'; import 'rxjs/add/observable/throw'; import 'rxjs/add/operator/map'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { GCAuthGuardService } from './gcauth-guard.service'; import {MappingEditorService} from '../../shared/services/mapping-editor.service'; import { promise } from 'protractor'; @@ -50,7 +50,7 @@ describe('LogginGuard', () => { loggedInGuard = TestBed.get(GCAuthGuardService); }); - it('be able to hit route when user is logged in', inject([GCAuthGuardService, MappingEditorService], (service: GCAuthGuardService, mapService: MappingEditorService) => { + it('be able to return true when referenceNameObjects is defined', inject([GCAuthGuardService, MappingEditorService], (service: GCAuthGuardService, mapService: MappingEditorService) => { localStorage['userId'] = 'abc@xyz.com'; mapService.referenceNameObjects = { data : 'data'}; let route : ActivatedRouteSnapshot; @@ -59,4 +59,15 @@ describe('LogginGuard', () => { expect(value).toBe(true); }) })); + + it('stop routing if referenceNameObjects is not defined', inject([GCAuthGuardService, MappingEditorService, NgbModal], (service: GCAuthGuardService, mapService: MappingEditorService, ngbModal: NgbModal) => { + localStorage['userId'] = 'abc@xyz.com'; + mapService.referenceNameObjects = undefined; + let spy = spyOn(NgbModal.prototype, 'open').and.returnValue(Promise.resolve(true)); + let route : ActivatedRouteSnapshot; + let state: RouterStateSnapshot; + service.canActivate(route, state).then((value)=>{ + expect(value).toBe(true); + }) + })); }); |