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 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 = {}) => {