LoginGuardService : added test case 05/59405/2
authorArundathi Patil <arundpil@in.ibm.com>
Tue, 7 Aug 2018 09:58:21 +0000 (15:28 +0530)
committerTakamune Cho <tc012c@att.com>
Tue, 7 Aug 2018 15:15:05 +0000 (15:15 +0000)
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>
src/app/vnfs/LoginGuardService/LoginGuardService.spec.ts

index 5e41d90..bf45684 100644 (file)
@@ -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);
+    }));
 });