Skip to content

Commit

Permalink
test(routing): use jest.spyOn()
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Apr 8, 2019
1 parent c83ad1b commit c78f21f
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/lib/__tests__/RoutingManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,26 +549,12 @@ describe('RoutingManager', () => {
});

describe('windowTitle', () => {
let setWindowTitle = jest.fn();

Object.defineProperty(window.document, 'title', {
get() {
return '';
},
set(value) {
setWindowTitle(value);
},
});

beforeEach(() => {
setWindowTitle = jest.fn();
});

test('should update the window title with URL query params on first render', async () => {
jsdom.reconfigure({
url: 'https://website.com/?query=query',
});

const setWindowTitle = jest.spyOn(window.document, 'title', 'set');
const searchClient = createFakeSearchClient();
const stateMapping = createFakeStateMapping();
const router = historyRouter({
Expand All @@ -595,6 +581,8 @@ describe('RoutingManager', () => {

expect(setWindowTitle).toHaveBeenCalledTimes(1);
expect(setWindowTitle).toHaveBeenLastCalledWith('Searching for "query"');

setWindowTitle.mockRestore();
});
});
});

0 comments on commit c78f21f

Please sign in to comment.