Skip to content

Commit 0a8c060

Browse files
committed
test: fix unit tests dues to jest breaking changes
1 parent 43e26dc commit 0a8c060

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

app/src/__tests__/components/pool/BatchStats.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('BatchStats', () => {
3333
expect(getByText('1m 30s')).toBeInTheDocument();
3434

3535
act(() => {
36-
jest.runTimersToTime(1000);
36+
jest.advanceTimersByTime(1000);
3737
});
3838
await waitFor(() => {
3939
expect(getByText('1m 29s')).toBeInTheDocument();

app/src/__tests__/store/batchStore.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,20 +254,22 @@ describe('BatchStore', () => {
254254
// allow polling in this test
255255
Object.defineProperty(config, 'IS_TEST', { get: () => false });
256256
jest.useFakeTimers();
257+
jest.spyOn(global, 'setInterval');
257258

258259
store.startPolling();
259-
expect(window.setInterval).toBeCalled();
260+
expect(setInterval).toBeCalled();
260261
expect(callCount).toBe(0);
261262
// fast forward 1 minute
262-
jest.runTimersToTime(60 * 1000);
263+
jest.advanceTimersByTime(60 * 1000);
263264
await waitFor(() => {
264265
expect(callCount).toBe(1);
265266
});
266267

268+
jest.spyOn(global, 'clearInterval');
267269
store.stopPolling();
268-
expect(window.clearInterval).toBeCalled();
270+
expect(clearInterval).toBeCalled();
269271
// fast forward 1 more minute
270-
jest.runTimersToTime(120 * 1000);
272+
jest.advanceTimersByTime(120 * 1000);
271273
expect(callCount).toBe(1);
272274

273275
// revert IS_TEST

0 commit comments

Comments
 (0)