Skip to content

Commit

Permalink
test fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Jan 28, 2025
1 parent 2ef959c commit 63e203c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/test/Shared/Services/Login.service.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { fromFetch } from 'rxjs/fetch';

jest.mock('rxjs/fetch', () => {
return {
fromFetch: jest.fn((_url: unknown, _opts: unknown): unknown => undefined),
fromFetch: jest.fn((_url: unknown, _opts: unknown): unknown => of()),
};
});

Expand Down Expand Up @@ -96,7 +96,7 @@ describe('Login.service', () => {
.mockReturnValueOnce(of(logoutResp));
window.location.href = 'https://example.com/';
location.href = window.location.href;
svc = new LoginService((p) => of(p), settingsSvc);
svc = new LoginService((p) => of(`.${p}`), settingsSvc);
});

it('should emit true', async () => {
Expand All @@ -105,14 +105,15 @@ describe('Login.service', () => {
});

it('should make expected API calls', async () => {
await firstValueFrom(svc.setLoggedOut());
expect(mockFromFetch).toHaveBeenCalledTimes(2);
expect(mockFromFetch).toHaveBeenCalledTimes(1);
expect(mockFromFetch).toHaveBeenNthCalledWith(1, `./api/v4/auth`, {
credentials: 'include',
mode: 'cors',
method: 'POST',
body: null,
});
await firstValueFrom(svc.setLoggedOut());
expect(mockFromFetch).toHaveBeenCalledTimes(2);
expect(mockFromFetch).toHaveBeenNthCalledWith(2, `./api/v4/logout`, {
credentials: 'include',
mode: 'cors',
Expand Down

0 comments on commit 63e203c

Please sign in to comment.