blob: 49d16d61b2b34797793f715b952de9dbdc7a18b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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();
});
});
|