From 3b247d43e994100d5a4fe386e272e6c191f20ac1 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 7 Aug 2018 15:28:21 +0530 Subject: LoginGuardService : added test case wrote test case to test canActivate function to navigate user to login page if the user is not logged in. Issue-ID: APPC-1064 Change-Id: Icc5a137474f69b8f9a8c2bc386ecc2b784f64ebb Signed-off-by: Arundathi Patil --- src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts b/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts index 5e41d90..bf45684 100644 --- a/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts +++ b/src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 IBM Intellectual Property. All rights reserved. +Copyright (C) 2018 IBM. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -16,8 +16,6 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -57,4 +55,11 @@ describe('LogginGuard', () => { let state: RouterStateSnapshot; expect(service.canActivate(route, state)).toBe(true); })); + + it('be able to navigate to login page when user is not logged in', inject([LoginGuardService], (service: LoginGuardService) => { + localStorage['userId'] = ''; + let route : ActivatedRouteSnapshot; + let mockSnapshot:any = jasmine.createSpyObj("RouterStateSnapshot", ['toString']); + expect(service.canActivate(route, mockSnapshot)).toBe(false); + })); }); -- cgit 1.2.3-korg