diff options
author | Arundathi Patil <arundpil@in.ibm.com> | 2018-08-07 15:28:21 +0530 |
---|---|---|
committer | Takamune Cho <tc012c@att.com> | 2018-08-07 15:15:05 +0000 |
commit | 3b247d43e994100d5a4fe386e272e6c191f20ac1 (patch) | |
tree | e675fec46f63d33c0e3015c8b7f88e07459fa4f5 | |
parent | ed8b4b56c819e622467e88b37e9e84fed69f09c1 (diff) |
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 <arundpil@in.ibm.com>
-rw-r--r-- | src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts | 11 |
1 files changed, 8 insertions, 3 deletions
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>("RouterStateSnapshot", ['toString']); + expect(service.canActivate(route, mockSnapshot)).toBe(false); + })); }); |