1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-18 21:51:49 +02:00
pigallery2/frontend/app/model/network/autehentication.service.spec.ts
Braun Patrik f9481c9f6e adding bootstrap to the project
Refactoring lightbox
2016-04-30 18:01:54 +02:00

42 lines
1.2 KiB
TypeScript

///<reference path="../../../browser.d.ts"/>
import {
it,
inject,
injectAsync,
beforeEachProviders,
TestComponentBuilder
} from 'angular2/testing';
import {provide} from 'angular2/core';
import {AuthenticationService} from "./authentication.service.ts";
import {UserService} from "./user.service.ts";
import {User} from "../../../../common/entities/User";
import {Message} from "../../../../common/entities/Message";
import "rxjs/Rx";
import {LoginCredential} from "../../../../common/entities/LoginCredential";
class MockUserService {
public login(credential:LoginCredential){
return Promise.resolve(new Message<User>(null,new User()))
}
}
describe('LoginService', () => {
beforeEachProviders(() => [
provide(UserService, {useClass: MockUserService}),
AuthenticationService
]);
it('should call User service login', inject([ AuthenticationService,UserService ], (authService, userService) => {
spyOn(userService,"login").and.callThrough();
expect(userService.login).not.toHaveBeenCalled();
authService.login();
expect(userService.login).toHaveBeenCalled();
}));
});