Skip to content

Instantly share code, notes, and snippets.

@vinnymac
Created February 1, 2023 03:24
Show Gist options
  • Save vinnymac/d2f0d9ccab1c43f52537ca652ec85a92 to your computer and use it in GitHub Desktop.
Save vinnymac/d2f0d9ccab1c43f52537ca652ec85a92 to your computer and use it in GitHub Desktop.
Example spec using mockWindowLocation
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