21020: Sort imports to follow PEP 8
[arvados.git] / services / workbench2 / 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 React from "react";
6 import { Button } from "@material-ui/core";
7 import { shallow, configure } from "enzyme";
8 import Adapter from "enzyme-adapter-react-16";
9 import { LAST_REFRESH_TIMESTAMP, 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         expect(localStorage.getItem(LAST_REFRESH_TIMESTAMP)).toBeFalsy();
35         // setup
36         const wrapper = shallow(<RefreshButton {...props} />);
37
38         // when
39         wrapper.find(Button).simulate('click');
40
41         // then
42         expect(props.history.replace).toHaveBeenCalledWith('/');
43         expect(localStorage.getItem(LAST_REFRESH_TIMESTAMP)).not.toBeFalsy();
44     });
45 });