2016-04-30 18:01:54 +02:00
|
|
|
///<reference path="../../../browser.d.ts"/>
|
2016-03-19 10:58:27 +02:00
|
|
|
|
|
|
|
import {
|
|
|
|
it,
|
|
|
|
inject,
|
|
|
|
injectAsync,
|
|
|
|
beforeEachProviders,
|
|
|
|
TestComponentBuilder
|
|
|
|
} from 'angular2/testing';
|
|
|
|
|
2016-03-19 11:55:46 +02:00
|
|
|
import {provide} from 'angular2/core';
|
2016-04-30 18:01:54 +02:00
|
|
|
import {AuthenticationService} from "./authentication.service.ts";
|
|
|
|
import {UserService} from "./user.service.ts";
|
|
|
|
import {User} from "../../../../common/entities/User";
|
|
|
|
import {Message} from "../../../../common/entities/Message";
|
2016-03-19 11:55:46 +02:00
|
|
|
import "rxjs/Rx";
|
2016-04-30 18:01:54 +02:00
|
|
|
import {LoginCredential} from "../../../../common/entities/LoginCredential";
|
2016-03-19 10:58:27 +02:00
|
|
|
|
2016-03-19 11:55:46 +02:00
|
|
|
class MockUserService {
|
|
|
|
public login(credential:LoginCredential){
|
|
|
|
return Promise.resolve(new Message<User>(null,new User()))
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 10:58:27 +02:00
|
|
|
|
|
|
|
describe('LoginService', () => {
|
|
|
|
beforeEachProviders(() => [
|
2016-03-19 11:55:46 +02:00
|
|
|
provide(UserService, {useClass: MockUserService}),
|
2016-03-19 10:58:27 +02:00
|
|
|
AuthenticationService
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
it('should call User service login', inject([ AuthenticationService,UserService ], (authService, userService) => {
|
2016-03-19 11:55:46 +02:00
|
|
|
spyOn(userService,"login").and.callThrough();
|
|
|
|
|
2016-03-19 10:58:27 +02:00
|
|
|
expect(userService.login).not.toHaveBeenCalled();
|
|
|
|
authService.login();
|
|
|
|
expect(userService.login).toHaveBeenCalled();
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
});
|