PATCH调用Angular服务测试

问题描述 投票:0回答:1

我有以下服务:

creerPass(mail: string, person: string, password: string): Observable<void> {
    const params = new HttpParams()
      .set('person', person)
      .set('mail', mail);
    return this.http.patch(`/api/user/pwd`, { password: password}, { params: params }).pipe(
      map(() => { }),
    )
  }

根据规格:

fit('should PATCH', () => {
    const person = "joe";
    const mail = "[email protected]"
    const password = "fezioOkf"

    passwordService.creerPass(mail, person, password).subscribe(() => { }, fail);
    const req = http.expectOne('/api/user/pwd');
    expect(req.request.method).toEqual('PATCH');

    // http.expectOne({ method: 'PATCH', url: '/api/user/pwd?person=joe&[email protected]`' });
  });

我收到以下错误:

Error: Expected one matching request for criteria "Match URL: api/user/pwd", found none.

如何使用参数和正文测试此请求?

angular testing service parameters patch
1个回答
0
投票

之后

© www.soinside.com 2019 - 2024. All rights reserved.