-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Labels
Description
These two tests don't actually test anything and should be refactored to handle the async call to fetch
consumerfinance.gov/test/unit_tests/apps/regulations3k/js/recent-notices-spec.js
Lines 81 to 103 in b252497
| 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.
Reactions are currently unavailable