summaryrefslogtreecommitdiffstats
path: root/frontend/__tests__/Nav.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/__tests__/Nav.test.js')
-rw-r--r--frontend/__tests__/Nav.test.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/frontend/__tests__/Nav.test.js b/frontend/__tests__/Nav.test.js
new file mode 100644
index 0000000..49d16d6
--- /dev/null
+++ b/frontend/__tests__/Nav.test.js
@@ -0,0 +1,35 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+import toJSON from 'enzyme-to-json';
+import { Nav } from '../components/Nav';
+
+const currentUserLoggedOut = {
+ refetch() {},
+};
+
+const currentUser = {
+ me: {},
+ refetch() {},
+};
+
+describe('<Nav></Nav>', () => {
+ it('renders', () => {
+ shallow(<Nav currentUser={currentUserLoggedOut} />);
+ });
+
+ it('Renders minimal nav when logged out', () => {
+ const wrapper = shallow(<Nav currentUser={currentUserLoggedOut} />);
+ expect(toJSON(wrapper)).toMatchSnapshot();
+ });
+
+ it('renders full nav when logged in', () => {
+ const wrapper = shallow(<Nav currentUser={currentUser} />);
+ expect(toJSON(wrapper)).toMatchSnapshot();
+ });
+
+ it('tries to refetch the current user when it mounts', () => {
+ const refetch = jest.fn();
+ shallow(<Nav currentUser={{ ...currentUser, refetch }} />);
+ expect(refetch).toHaveBeenCalled();
+ });
+});