mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 12:49:48 -04:00
Switch to jest.spyOn() for window.location
The previous comment was incorrect, so there's no need to use the defineObject hack, or to populate the object beforehand.
This commit is contained in:
@@ -46,12 +46,9 @@ describe('Register security key', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// pretend window.location exists in test env
|
jest.spyOn(window.location, 'reload').mockImplementation(() => {
|
||||||
Object.defineProperty(window, 'location', {
|
|
||||||
// signal that the async promise chain was called
|
// signal that the async promise chain was called
|
||||||
value: { reload: () => done() },
|
done()
|
||||||
// allow global property to be redefined in other tests
|
|
||||||
writable: true,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
jest.spyOn(window, 'fetch').mockImplementation((_url, options = {}) => {
|
jest.spyOn(window, 'fetch').mockImplementation((_url, options = {}) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user