1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-16 11:37:13 +02:00
pigallery2/frontend/app/model/autehentication.service.spec.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

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