-
Notifications
You must be signed in to change notification settings - Fork 470
Expand file tree
/
Copy pathCompareHome.test.tsx
More file actions
49 lines (40 loc) · 1.52 KB
/
CompareHome.test.tsx
File metadata and controls
49 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { Provider } from 'react-redux';
import { fireEvent } from '@testing-library/react';
import { render } from 'firefox-profiler/test/fixtures/testing-library';
import { CompareHome } from '../../components/app/CompareHome';
import { getProfilesToCompare } from '../../selectors/url-state';
import { blankStore } from '../fixtures/stores';
import { fireFullClick } from '../fixtures/utils';
describe('app/CompareHome', () => {
function setup() {
const store = blankStore();
const renderResult = render(
<Provider store={store}>
<CompareHome />
</Provider>
);
return { ...renderResult, getState: store.getState };
}
it('matches the snapshot', () => {
const { container } = setup();
expect(container.firstChild).toMatchSnapshot();
});
it('starts loading profiles after user action', () => {
const { getByLabelText, getByText, getState } = setup();
fireEvent.change(getByLabelText(/Profile 1/), {
target: { value: 'http://www.url11.com' },
});
fireEvent.change(getByLabelText(/Profile 2/), {
target: { value: 'http://www.url12.com' },
});
const retrieveButton = getByText(/Retrieve/);
fireFullClick(retrieveButton);
expect(getProfilesToCompare(getState())).toEqual([
'http://www.url11.com',
'http://www.url12.com',
]);
});
});