summaryrefslogtreecommitdiffstats
path: root/frontend/__tests__/Nav.test.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-03-14 12:19:54 -0400
committerWes Bos <wesbos@gmail.com>2018-03-14 12:19:54 -0400
commit331da87bd53bc1fb79063d142764c75df9f32170 (patch)
treed80aac98154a811fdf57b10e90ac0350fe14568e /frontend/__tests__/Nav.test.js
parent46a0ba30ef54a7e36206481a4f5b2bf1f9702fca (diff)
tests
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();
+ });
+});