Skip to content

Commit

Permalink
test(core): ✅ add request tests for cache status
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfoucrier committed Apr 28, 2023
1 parent 1d2d1c1 commit d4bcf57
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/__tests__/utils/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ it('throws fetch error', async () => {

await expect(request(url, 2e3, requestError, barba.cache)).rejects.toEqual(error);
expect(requestError).toHaveBeenCalledWith(url, error);
expect(barba.cache.getStatus(url)).toEqual('rejected');
});

it('throws result error with 404', async () => {
Expand All @@ -53,6 +54,7 @@ it('throws result error with 404', async () => {

await expect(request(url, 2e3, requestError, barba.cache)).rejects.toEqual(error);
expect(requestError).toHaveBeenCalledWith(url, error);
expect(barba.cache.getStatus(url)).toEqual('rejected');
});

it('throws timeout error', async () => {
Expand All @@ -62,6 +64,7 @@ it('throws timeout error', async () => {

await expect(request(url, 100, requestError, barba.cache)).rejects.toEqual(error);
expect(requestError).toHaveBeenCalledWith(url, error);
expect(barba.cache.getStatus(url)).toEqual('rejected');
}, 1000);

it('fetch text content', async () => {
Expand All @@ -70,6 +73,7 @@ it('fetch text content', async () => {
await expect(request(url, undefined, requestError, barba.cache)).resolves.toBe('content');
// expect((global as any).window.clearTimeout).toHaveBeenCalledTimes(1);
expect(requestError).not.toHaveBeenCalled();
expect(barba.cache.getStatus(url)).toEqual('fulfilled');
});

// it('throws bad connection error', async () => {
Expand Down

0 comments on commit d4bcf57

Please sign in to comment.