fix(fixed faiing test)

Co-authored-by: Sebastian Palmqvist <PalmN72@users.noreply.github.com>
This commit is contained in:
Lee 2023-10-12 14:23:58 +02:00
parent fced5b0abb
commit 39d5e64078
1 changed files with 12 additions and 3 deletions

View File

@ -48,8 +48,17 @@ test('can run many tasks', async () => {
expect(result).toEqual(['one', 'two', 'three']);
});
test.skip('sets up timer on fetch', () => {
sut.fetch(async () => 'one', 'one');
// test('sets up timer on fetch', () => {
// sut.fetch(async () => 'one', 'one');
expect(setTimeout).toHaveBeenCalledTimes(1);
// expect(setTimeout).toHaveBeenCalledTimes(1);
// });
test('sets up timer on fetch', () => {
const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
sut.fetch(async () => 'one', 'one');
expect(setTimeoutSpy).toHaveBeenCalledTimes(1);
// Restore the original setTimeout function
setTimeoutSpy.mockRestore();
});