-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTicketsPage.test.js
52 lines (41 loc) · 1.54 KB
/
TicketsPage.test.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React from 'react';
import { render } from 'enzyme';
import TicketsPage from './TicketsPage';
describe('TicketsPage Structural with Enzyme', () => {
describe('when loading tickets', () => {
const wrapper = render(<TicketsPage loading tickets={[]} />);
it('should render spinner only', () => {
//console.log(wrapper.html());
expect(wrapper.find('h1').text()).toEqual('Your Tickets');
expect(wrapper.find('.spinner').length).toEqual(1);
});
});
describe('when there is an error', () => {
const wrapper = render(<TicketsPage error='mock err' tickets={[]} />);
it('should render error alert', () => {
//console.log(wrapper.html());
expect(wrapper.find('p').text()).toEqual('mock err');
expect(wrapper.find('.alert').length).toEqual(1);
});
});
describe('when there are no tickets', () => {
const wrapper = render(<TicketsPage tickets={[]} />);
it('should render empty message', () => {
//console.log(wrapper.html());
expect(wrapper.find('p').text()).toEqual('There are no tickets.');
//expect(wrapper.html()).toMatchSnapshot();
});
});
});
// import React from 'react';
// import renderer from 'react-test-renderer';
// import TicketsPage from './TicketsPage';
// describe('TicketsPage (Snapshot)', () => {
// describe('when there are no tickets', () => {
// it('should render empty message', () => {
// const component = renderer.create(<TicketsPage tickets={[]} />);
// const json = component.toJSON();
// expect(json).toMatchSnapshot();
// });
// });
// });