mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
update tests
This commit is contained in:
parent
1ec6ed6985
commit
10b47c45eb
@ -3,7 +3,6 @@
|
|||||||
import {
|
import {
|
||||||
it,
|
it,
|
||||||
inject,
|
inject,
|
||||||
injectAsync,
|
|
||||||
beforeEachProviders
|
beforeEachProviders
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ import {AuthenticationService} from "./authentication.service";
|
|||||||
|
|
||||||
class MockUserService {
|
class MockUserService {
|
||||||
public login(credential:LoginCredential){
|
public login(credential:LoginCredential){
|
||||||
return Promise.resolve(new Message<User>(null,new User()))
|
return Promise.resolve(new Message<User>(null,new User(0,"testUserName")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +45,7 @@ describe('AuthenticationService', () => {
|
|||||||
it('should have Authenticated use', inject([ AuthenticationService ], (authService) => {
|
it('should have Authenticated use', inject([ AuthenticationService ], (authService) => {
|
||||||
spyOn(authService.OnAuthenticated,"trigger").and.callThrough();
|
spyOn(authService.OnAuthenticated,"trigger").and.callThrough();
|
||||||
authService.login();
|
authService.login();
|
||||||
|
expect(authService.OnAuthenticated.trigger).toHaveBeenCalled();
|
||||||
authService.OnAuthenticated.on(() =>{
|
authService.OnAuthenticated.on(() =>{
|
||||||
expect(authService.getUser()).not.toBe(null);
|
expect(authService.getUser()).not.toBe(null);
|
||||||
expect(authService.isAuthenticated()).toBe(true);
|
expect(authService.isAuthenticated()).toBe(true);
|
||||||
|
@ -35,12 +35,14 @@ describe('UserService', () => {
|
|||||||
spyOn(networkService,"postJson");
|
spyOn(networkService,"postJson");
|
||||||
let credential = new LoginCredential("name","pass");
|
let credential = new LoginCredential("name","pass");
|
||||||
userService.login(credential);
|
userService.login(credential);
|
||||||
|
expect(networkService.getJson).toHaveBeenCalled();
|
||||||
expect(networkService.postJson.calls.argsFor(0)).toEqual(["/user/login",{"loginCredential": credential}]);
|
expect(networkService.postJson.calls.argsFor(0)).toEqual(["/user/login",{"loginCredential": credential}]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should call getJson at getSessionUser', inject([UserService,NetworkService], (userService,networkService) => {
|
it('should call getJson at getSessionUser', inject([UserService,NetworkService], (userService,networkService) => {
|
||||||
spyOn(networkService,"getJson");
|
spyOn(networkService,"getJson");
|
||||||
userService.getSessionUser();
|
userService.getSessionUser();
|
||||||
|
expect(networkService.getJson).toHaveBeenCalled();
|
||||||
expect(networkService.getJson.calls.argsFor(0)).toEqual(["/user/login"]);
|
expect(networkService.getJson.calls.argsFor(0)).toEqual(["/user/login"]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user