|
1 | 1 | import React from 'react'; |
2 | | -import { mount } from 'enzyme'; |
| 2 | +import { createMount, createShallow } from '@material-ui/core/test-utils'; |
3 | 3 |
|
4 | 4 | import Home from '../../../app/components/Home'; |
5 | | -import { DashboardContext } from '../../../app/context/DashboardContext'; |
6 | | - |
7 | 5 |
|
8 | 6 | describe('<Home />', () => { |
9 | 7 | let wrapper: any; |
| 8 | + let mount: any; |
| 9 | + let shallow: any; |
10 | 10 |
|
11 | | - beforeAll(() => { |
12 | | - const applications: any = []; |
13 | | - const getApplications: any = jest.fn(); |
14 | | - |
15 | | - const mockHome = ( |
16 | | - <DashboardContext.Provider value={{ applications, getApplications }}> |
17 | | - <Home /> |
18 | | - </DashboardContext.Provider> |
19 | | - ); |
20 | | - wrapper = mount(mockHome); |
| 11 | + beforeEach(() => { |
| 12 | + mount = createMount(); |
| 13 | + shallow = createShallow(); |
21 | 14 | }); |
22 | 15 |
|
23 | | - it('should render an <img/> tag of the Chronos pangolin', () => { |
24 | | - const image = wrapper.find('img'); |
25 | | - expect(image).toBeDefined(); |
26 | | - |
27 | | - const imageProps = image.props(); |
28 | | - expect(imageProps).toHaveProperty('width'); |
29 | | - expect(imageProps).toHaveProperty('height'); |
30 | | - expect(imageProps).toHaveProperty('src'); |
31 | | - expect(imageProps).toHaveProperty('alt'); |
| 16 | + afterEach(() => { |
| 17 | + mount.cleanUp(); |
32 | 18 | }); |
33 | 19 |
|
34 | | - it("should render an <h1> tag that says 'Welcome to Chronos!'", () => { |
35 | | - const h1Tag = wrapper.find('h1'); |
36 | | - expect(h1Tag.text()).toMatch('Welcome to Chronos!'); |
| 20 | + it("should render an <p> tag that says 'Your all-in-one application monitoring tool'", () => { |
| 21 | + const wrapper = shallow(<Home />); |
| 22 | + const pTag = wrapper.find('p'); |
| 23 | + expect(pTag.text()).toMatch('Your all-in-one application monitoring tool'); |
37 | 24 | }); |
38 | 25 |
|
39 | 26 | it("should render a <Link> tag that is labeled 'Get Started'", () => { |
| 27 | + const wrapper = shallow(<Home />); |
40 | 28 | const linkTag = wrapper.find('Link'); |
41 | 29 | expect(linkTag).toBeDefined(); |
42 | | - expect(linkTag.text()).toMatch('Get started'); |
| 30 | + expect(linkTag.text()).toMatch('Get Started'); |
43 | 31 | expect(linkTag.prop('to')).toEqual('/applications'); |
44 | 32 | }); |
45 | 33 | }); |
0 commit comments