16627: Added refresh button to main contet bar
[arvados-workbench2.git] / src / components / refresh-button / refresh-button.test.tsx
diff --git a/src/components/refresh-button/refresh-button.test.tsx b/src/components/refresh-button/refresh-button.test.tsx
new file mode 100644 (file)
index 0000000..f6372e5
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Button } from "@material-ui/core";
+import { shallow, configure } from "enzyme";
+import * as Adapter from "enzyme-adapter-react-16";
+import { RefreshButton } from './refresh-button';
+
+configure({ adapter: new Adapter() });
+
+describe('<RefreshButton />', () => {
+    let props;
+
+    beforeEach(() => {
+        props = {
+            history: {
+                push: jest.fn(),
+            },
+            classes: {},
+        };
+    });
+
+    it('should render without issues', () => {
+        // when
+        const wrapper = shallow(<RefreshButton {...props} />);
+
+        // then
+        expect(wrapper.html()).toContain('button');
+    });
+
+    it('should pass window location to router', () => {
+        // setup
+        const wrapper = shallow(<RefreshButton {...props} />);
+
+        // when
+        wrapper.find(Button).simulate('click');
+
+        // then
+        expect(props.history.push).toHaveBeenCalledWith('/');
+    });
+});