ngneat/spectator

When use createHttpFactory for test intercptor HttpResond url is null

lme-agicap opened this issue · 1 comments

Is this a regression?

No

Description

My test

  let spectator: SpectatorHttp<EnvironmentInterceptor>;
  const createHttp = createHttpFactory({
    service: EnvironmentInterceptor
  });
  
  beforeEach(() => {
    spectator = createHttp();
  });

  test('not rewriting url', async(() => {
    const mockHandler = {
      handle: jest.fn(() => of(new HttpResponse({status: 200, body: {}})))
    };
    spectator.service.intercept(new HttpRequest<unknown>(HttpMethod.GET, '/anything'), mockHandler).subscribe((response) => {
      expect(response instanceof HttpResponse).toBeTruthy();
      console.log(response);
      expect((response as HttpResponse<any>).url).toEqual('/anything');
    });
  }));

This test failed because response.url is null.
The purpose of my interceptor is to rewrite the following given url, I can't test this case

I think when using the service with the mockHandler it doesn't create the response with the url correctly.

I will try to investigate to see where the problem comes from.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

Yes

Sorry is my fault in mockHandler not set URL, my test is not good.