fe7b609d230b27808306f366943022a7c7df6f7e
[arvados-workbench2.git] / src / components / refresh-button / refresh-button.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { Button } from "@material-ui/core";
7 import { shallow, configure } from "enzyme";
8 import * as Adapter from "enzyme-adapter-react-16";
9 import { RefreshButton } from './refresh-button';
10
11 configure({ adapter: new Adapter() });
12
13 describe('<RefreshButton />', () => {
14     let props;
15
16     beforeEach(() => {
17         props = {
18             history: {
19                 replace: jest.fn(),
20             },
21             classes: {},
22         };
23     });
24
25     it('should render without issues', () => {
26         // when
27         const wrapper = shallow(<RefreshButton {...props} />);
28
29         // then
30         expect(wrapper.html()).toContain('button');
31     });
32
33     it('should pass window location to router', () => {
34         // setup
35         const wrapper = shallow(<RefreshButton {...props} />);
36
37         // when
38         wrapper.find(Button).simulate('click');
39
40         // then
41         expect(props.history.replace).toHaveBeenCalledWith('/');
42     });
43 });