У меня есть эта функция входа в систему, и я хотел бы проверить ее. Но я получаю сообщение об ошибке «Асинхронный обратный вызов не был вызван в течение 5000 мс»
public async Login(email: string, password: string): Promise<any> {
const body = { email, password };
await this.getCSRFToken().toPromise();
return this.http
.post<any>(this.baseUrl + 'login', body)
.pipe(
tap(data => {
this.user = data;
return this.user;
})
)
.toPromise();
}
Мой тест:
it('should login', (done) => {
const service: AuthenticationService = TestBed.get(AuthenticationService);
const http = TestBed.get(HttpTestingController);
let userResponse;
service.Login('email', 'password').then((response) => {
userResponse = response;
});
http.expectOne((req) => {
return req.method === 'POST'
&& req.url === '/frontend/login';
}).flush({user_type: 'Test'});
expect(userResponse).toEqual({user_type: 'Test'});
});
Есть идеи ??