Passed
Pull Request — main (#343)
by Alejandro
04:07
created

test/common/NotFound.test.tsx   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 48
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 40
mnd 1
bc 1
fnc 0
dl 0
loc 48
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
1
import { shallow, ShallowWrapper } from 'enzyme';
2
import { Link } from 'react-router-dom';
3
import NotFound from '../../src/common/NotFound';
4
5
describe('<NotFound />', () => {
6
  let wrapper: ShallowWrapper;
7
  const createWrapper = (props = {}) => {
8
    wrapper = shallow(<NotFound {...props} />);
9
    const content = wrapper.text();
10
11
    return { wrapper, content };
12
  };
13
14
  afterEach(() => wrapper?.unmount());
15
16
  it('shows expected error title', () => {
17
    const { content } = createWrapper();
18
19
    expect(content).toContain('Oops! We could not find requested route.');
20
  });
21
22
  it('shows expected error message', () => {
23
    const { content } = createWrapper();
24
25
    expect(content).toContain(
26
      'Use your browser\'s back button to navigate to the page you have previously come from, or just press this button.',
27
    );
28
  });
29
30
  it('shows a link to the home', () => {
31
    const { wrapper } = createWrapper();
32
    const link = wrapper.find(Link);
33
34
    expect(link.prop('to')).toEqual('/');
35
    expect(link.prop('className')).toEqual('btn btn-outline-primary btn-lg');
36
    expect(link.prop('children')).toEqual('Home');
37
  });
38
39
  it('shows a link with provided props', () => {
40
    const { wrapper } = createWrapper({ to: '/foo/bar', children: 'Hello' });
41
    const link = wrapper.find(Link);
42
43
    expect(link.prop('to')).toEqual('/foo/bar');
44
    expect(link.prop('className')).toEqual('btn btn-outline-primary btn-lg');
45
    expect(link.prop('children')).toEqual('Hello');
46
  });
47
});
48