Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regs3k asynchronous tests aren't testing anything #7374

Open
anselmbradford opened this issue Nov 29, 2022 · 0 comments
Open

Regs3k asynchronous tests aren't testing anything #7374

anselmbradford opened this issue Nov 29, 2022 · 0 comments

Comments

@anselmbradford
Copy link
Member

These two tests don't actually test anything and should be refactored to handle the async call to fetch

it('should load recent notices', () => {
// Fire `load` event
simulateEvent('load', window, { currentTarget: window });
// Wait for window.load to trigger.
setTimeout(() => {
const numNotices = document.querySelectorAll('.m-list_link').length;
expect(numNotices).toEqual(4);
}, 1000);
});
it('should fail to load recent notices', (done) => {
fetch.mockReject(new Error('Server error!'));
// Fire `load` event
simulateEvent('load', window, { currentTarget: window });
setTimeout(() => {
// eslint-disable-next-line no-console
expect(console.error).toBeCalled();
done();
}, 100);
});

The call to fetch happens inside a window.onload event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant