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:
Ben Thorner
2021-05-12 17:31:18 +01:00
parent aae01bf8e2
commit 35507683ee

View File

@@ -46,12 +46,9 @@ describe('Register security key', () => {
})
})
// pretend window.location exists in test env
Object.defineProperty(window, 'location', {
jest.spyOn(window.location, 'reload').mockImplementation(() => {
// signal that the async promise chain was called
value: { reload: () => done() },
// allow global property to be redefined in other tests
writable: true,
done()
})
jest.spyOn(window, 'fetch').mockImplementation((_url, options = {}) => {