Skip to content

Commit

Permalink
Wrap timers with act
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed May 25, 2023
1 parent caa77fb commit 13def81
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions frontend/src/components/taskSelection/tests/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ describe('Task Map Action', () => {
});

describe('Session Expire Dialogs', () => {
beforeEach(() => {
act(() => jest.useFakeTimers());
beforeEach(async () => {
await act(() => jest.useFakeTimers());
});

afterEach(() => {
act(() => jest.runOnlyPendingTimers());
afterEach(async () => {
await act(() => jest.runOnlyPendingTimers());
jest.useRealTimers();
});

it('should display modal to notify user session about to expire', async () => {
setup();
act(() => jest.advanceTimersByTime(6900000));
await act(() => jest.advanceTimersByTime(6900000));
const extendSessionDialog = screen.getByRole('dialog');
expect(within(extendSessionDialog).getByRole('heading')).toHaveTextContent(
messages.sessionAboutToExpireTitle.defaultMessage,
Expand All @@ -91,7 +91,7 @@ describe('Session Expire Dialogs', () => {

it('should display modal to notify user session has ended', async () => {
setup();
act(() => jest.advanceTimersByTime(7200000));
await act(() => jest.advanceTimersByTime(7200000));
const extendSessionDialog = screen.getByRole('dialog');
expect(within(extendSessionDialog).getByRole('heading')).toHaveTextContent(
messages.sessionExpiredTitle.defaultMessage,
Expand Down

0 comments on commit 13def81

Please sign in to comment.