Created
February 1, 2023 03:24
-
-
Save vinnymac/d2f0d9ccab1c43f52537ca652ec85a92 to your computer and use it in GitHub Desktop.
Example spec using mockWindowLocation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render } from '@testing-library/react'; | |
import AutoRedirect from './AutoRedirect'; | |
import { mockWindowLocation } from './testUtils'; | |
describe('Navigation', () => { | |
mockWindowLocation(); | |
it('navigates to seatgeek', () => { | |
render(<AutoRedirect />); | |
expect(window.location.assign).toHaveBeenCalledTimes(1); | |
expect(window.location.assign).toHaveBeenCalledWith( | |
'https://seatgeek.com', | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment