From 10b47c45eb2c0dcb84a03b22621f95a00240176a Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Thu, 5 May 2016 18:05:40 +0200 Subject: [PATCH] update tests --- frontend/app/model/network/autehentication.service.spec.ts | 4 ++-- frontend/app/model/network/user.service.spec.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/app/model/network/autehentication.service.spec.ts b/frontend/app/model/network/autehentication.service.spec.ts index 597355f7..34d63f14 100644 --- a/frontend/app/model/network/autehentication.service.spec.ts +++ b/frontend/app/model/network/autehentication.service.spec.ts @@ -3,7 +3,6 @@ import { it, inject, - injectAsync, beforeEachProviders } from '@angular/core/testing'; @@ -18,7 +17,7 @@ import {AuthenticationService} from "./authentication.service"; class MockUserService { public login(credential:LoginCredential){ - return Promise.resolve(new Message(null,new User())) + return Promise.resolve(new Message(null,new User(0,"testUserName"))) } } @@ -46,6 +45,7 @@ describe('AuthenticationService', () => { it('should have Authenticated use', inject([ AuthenticationService ], (authService) => { spyOn(authService.OnAuthenticated,"trigger").and.callThrough(); authService.login(); + expect(authService.OnAuthenticated.trigger).toHaveBeenCalled(); authService.OnAuthenticated.on(() =>{ expect(authService.getUser()).not.toBe(null); expect(authService.isAuthenticated()).toBe(true); diff --git a/frontend/app/model/network/user.service.spec.ts b/frontend/app/model/network/user.service.spec.ts index 324e0dfc..b230cb83d 100644 --- a/frontend/app/model/network/user.service.spec.ts +++ b/frontend/app/model/network/user.service.spec.ts @@ -35,12 +35,14 @@ describe('UserService', () => { spyOn(networkService,"postJson"); let credential = new LoginCredential("name","pass"); userService.login(credential); + expect(networkService.getJson).toHaveBeenCalled(); expect(networkService.postJson.calls.argsFor(0)).toEqual(["/user/login",{"loginCredential": credential}]); })); it('should call getJson at getSessionUser', inject([UserService,NetworkService], (userService,networkService) => { spyOn(networkService,"getJson"); userService.getSessionUser(); + expect(networkService.getJson).toHaveBeenCalled(); expect(networkService.getJson.calls.argsFor(0)).toEqual(["/user/login"]); }));