Skip to content

Commit 52c3121

Browse files
Merge branch 'app-tests' of https://github.com/gregpalace/Chronos into staging-master
2 parents 66aaeb6 + 42f6ca0 commit 52c3121

5 files changed

Lines changed: 138 additions & 45 deletions

File tree

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,35 @@
1-
xdescribe('<Applications />', () => {
2-
it('should');
1+
import React from 'react';
2+
import { mount } from 'enzyme';
3+
import { createMount, createShallow } from '@material-ui/core/test-utils';
4+
5+
import Applications from '../../../app/components/Applications';
6+
import { DashboardContext } from '../../../app/context/DashboardContext';
7+
8+
describe('React unit tests', () => {
9+
describe('<Application/>', () => {
10+
let wrapper: any;
11+
let mount: any;
12+
let shallow: any;
13+
14+
beforeAll(() => {
15+
const applications: any = [];
16+
const getApplications: any = jest.fn();
17+
mount = createMount();
18+
shallow = createShallow();
19+
20+
wrapper = mount(
21+
<DashboardContext.Provider value={{ applications, getApplications }}>
22+
<Applications />
23+
</DashboardContext.Provider>
24+
);
25+
});
26+
27+
afterAll(() => {
28+
mount.cleanUp();
29+
});
30+
31+
it('should render properly', () => {
32+
expect(wrapper).toMatchSnapshot();
33+
});
34+
});
335
});
4-
5-
6-
// import React from 'react';
7-
// import { configure, shallow, mount } from 'enzyme';
8-
// import { expect } from 'chai';
9-
// import { createShallow } from '@material-ui/core/test-utils';
10-
// import Adapter from 'enzyme-adapter-react-16';
11-
12-
// // Import our Component and Icons
13-
// import Applications from '../../../app/components/Applications';
14-
// import DeleteForeverOutlinedIcon from '@material-ui/icons/DeleteForeverOutlined';
15-
16-
// configure({ adapter: new Adapter() });
17-
18-
// describe('React unit tests', () => {
19-
// describe('<Applications />', () => {
20-
// let wrapper;
21-
22-
// beforeAll(() => {
23-
// wrapper = shallow(<Applications />);
24-
// // shallow = createShallow();
25-
// });
26-
27-
// xit('Should render a delete icon', () => {
28-
// // expect(wrapper.find(<DeleteForeverOutlinedIcon />));
29-
// });
30-
31-
// xit('Should have delete functionality', () => {});
32-
33-
// xit('Should contain grid items', () => {});
34-
35-
// xit('Should have three grid items', () => {
36-
// const wrapper = shallow(<Applications />);
37-
// expect(wrapper.toHaveLength(3));
38-
// });
39-
// });
40-
// });
Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1-
xdescribe('<Copyright />', () => {
2-
it('should');
1+
import React from 'react';
2+
import Enzyme, { mount } from 'enzyme';
3+
import { createMount, createShallow } from '@material-ui/core/test-utils';
4+
import { Link, Typography } from '@material-ui/core';
5+
import Adapter from 'enzyme-adapter-react-16';
6+
7+
import Copyright from '../../../app/components/Copyright';
8+
9+
Enzyme.configure({ adapter: new Adapter() });
10+
11+
describe('React unit test', () => {
12+
describe('<Copyright/>', () => {
13+
let wrapper: any;
14+
let mount: any;
15+
let shallow: any;
16+
17+
beforeEach(() => {
18+
mount = createMount();
19+
shallow = createShallow();
20+
});
21+
22+
afterEach(() => {
23+
mount.cleanUp();
24+
});
25+
26+
it('renders correctly', () => {
27+
const wrapper = shallow(<Copyright />);
28+
expect(wrapper).toMatchSnapshot();
29+
});
30+
31+
it('should contain link to chronos website', () => {
32+
const wrapper = shallow(<Copyright />);
33+
expect(wrapper.find(Link)).toHaveLength(1);
34+
expect(wrapper.find(Link).prop('href'));
35+
expect(wrapper.find(Link).prop('href')).toEqual('https://chronoslany.com/');
36+
});
37+
38+
xit('should route user to Chronos website', () => {
39+
const wrapper = shallow(<Copyright />);
40+
const mockedHandleClick = jest.fn();
41+
wrapper.instance().handleClick = mockedHandleClick;
42+
expect(mockedHandleClick).toHaveBeenCalledTimes(1);
43+
});
44+
45+
it('should render <Typography /> to display copyright info', () => {
46+
const wrapper = shallow(<Copyright />);
47+
expect(wrapper.find(Typography)).toHaveLength(1);
48+
expect(wrapper.find(Typography).text()).toMatch('Team Chronos');
49+
});
50+
});
351
});
Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1-
xdescribe('<Occupied />', () => {
2-
it('should');
1+
import React from 'react';
2+
import Enzyme, { mount } from 'enzyme';
3+
import { Typography, Grid, Button } from '@material-ui/core';
4+
import { createMount, createShallow } from '@material-ui/core/test-utils';
5+
import Adapter from 'enzyme-adapter-react-16';
6+
7+
import Occupied from '../../../app/components/Occupied';
8+
9+
Enzyme.configure({ adapter: new Adapter() });
10+
11+
describe('React unit test', () => {
12+
describe('<Occupied />', () => {
13+
let mount: any;
14+
let shallow: any;
15+
16+
beforeEach(() => {
17+
mount = createMount();
18+
shallow = createShallow();
19+
});
20+
21+
afterEach(() => {
22+
mount.cleanUp();
23+
});
24+
25+
it('Renders correctly', () => {
26+
const wrapper = shallow(<Occupied />);
27+
console.log(wrapper.debug());
28+
expect(wrapper).toMatchSnapshot();
29+
});
30+
31+
it('should display text of our application page', () => {
32+
const wrapper = shallow(<Occupied />);
33+
expect(wrapper.find(Typography).text()).toMatch('Applications');
34+
});
35+
36+
it('should render a grid containing our applications', () => {
37+
const wrapper = shallow(<Occupied />);
38+
expect(wrapper.find(Grid)).toHaveLength(1);
39+
expect(wrapper.find(Grid).prop('container'));
40+
expect(wrapper.find(Grid).prop('spacing'));
41+
});
42+
43+
it('should render a button with an onClick attribute', () => {
44+
const wrapper = shallow(<Occupied />);
45+
const mockOnClick = jest.fn();
46+
const button = wrapper.find(Button);
47+
// button.simulate('click');
48+
expect(button).toHaveLength(1);
49+
expect(button.prop('onClick'));
50+
expect(mockOnClick.mock.calls.length).toBe(0);
51+
});
52+
});
353
});

app/components/Applications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext, useEffect, useState } from 'react';
2-
import { Grid, IconButton, Modal, Card, CardActions, Paper } from '@material-ui/core';
2+
import { Grid, IconButton, Modal, Paper } from '@material-ui/core';
33
import DeleteForeverOutlinedIcon from '@material-ui/icons/DeleteForeverOutlined';
44
import { makeStyles } from '@material-ui/core/styles';
55
import { DashboardContext } from '../context/DashboardContext';

app/components/Copyright.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface CopyrightProps {}
66
const Copyright = () => (
77
<Typography variant="body2" color="textSecondary" align="center">
88
{'Copyright © '}
9-
<Link color="inherit" href="https://material-ui.com/">
9+
<Link color="inherit" href="https://chronoslany.com/">
1010
Team Chronos
1111
</Link>{' '}
1212
{new Date().getFullYear()}

0 commit comments

Comments
 (0)