aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2018-08-06 16:39:01 +0530
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>2018-08-06 16:39:15 +0530
commita64e331255206eb2c2a8b0d2503762cbc5ac9751 (patch)
tree16021ceaae10710187c64a200b494640cfa3e1b2
parent5e57bd7a7093cd1ac6a0cfc026c0103fd8afc149 (diff)
gcauth.guard.service - added test case
Added test case to cover canActivate method when referenceObject is not defined. Issue-ID: APPC-1064 Change-Id: I19d08cf1e0b6426e52d1db48be89ed8e76864560 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
-rw-r--r--src/app/vnfs/GCAuthGuard/gcauth.guard.spec.ts15
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);
+ })
+ }));
});