Commit c9061ac8 authored by Maxime REYROLLE's avatar Maxime REYROLLE

rework should not authenticate a user test

parent ad6340ed
......@@ -67,26 +67,20 @@ describe('AuthenticationService', () => {
httpMock.verify();
}));
it('should not authenticate a user', inject([AuthenticationService, MockBackend],
fakeAsync((authenticationService: AuthenticationService, mockBackend: MockBackend) => {
let result;
it('should not authenticate a user', inject([AuthenticationService, HttpTestingController],
(authenticationService: AuthenticationService, httpMock: HttpTestingController) => {
const expectedBody = {};
mockBackend.connections.subscribe(connection => {
expect(connection.request.method).toBe(RequestMethod.Get);
expect(connection.request.url).toBe('https://cake.test.adullact.org/api/v1/users/token.json');
const options = new ResponseOptions({status: 200, body: expectedBody});
connection.mockRespond(new Response(options));
});
authenticationService.authenticate().subscribe(body => {
result = body;
authenticationService.authenticate().subscribe(data => {
expect(data).toBeFalsy();
});
tick();
const req = httpMock.expectOne('https://cake.test.adullact.org/api/v1/users/token.json');
expect(result).toBeFalsy();
})));
expect(req.request.method).toEqual('GET');
req.flush(expectedBody);
httpMock.verify();
}));
});
describe('logout()', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment