Skip to content

Commit 5b805ee

Browse files
authored
Merge pull request #62 from oslabs-beta/staging-faast
Finished Enzyme test cases by Fredo
2 parents 8a7aa5a + d676cf6 commit 5b805ee

File tree

3 files changed

+87
-15
lines changed

3 files changed

+87
-15
lines changed
Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Enzyme testing suite renders snapshots, too 1`] = `
4-
<div>
5-
<h1>
6-
Hello, Enzyme!
7-
</h1>
3+
exports[`Test the BottomTabs component Matches snapshot 1`] = `
4+
<div
5+
className="makeStyles-root-1"
6+
>
7+
<Styled(MuiBox)
8+
display="flex"
9+
justifyContent="space-between"
10+
>
11+
<WithStyles(ForwardRef(Tabs))
12+
classes={
13+
Object {
14+
"indicator": "makeStyles-tabsIndicator-4",
15+
"root": "makeStyles-tabsRoot-3",
16+
}
17+
}
18+
onChange={[Function]}
19+
value={0}
20+
>
21+
<WithStyles(ForwardRef(Tab))
22+
classes={
23+
Object {
24+
"root": "makeStyles-tabRoot-5",
25+
"selected": "makeStyles-tabSelected-6",
26+
}
27+
}
28+
disableRipple={true}
29+
label="Code Preview"
30+
/>
31+
</WithStyles(ForwardRef(Tabs))>
32+
</Styled(MuiBox)>
33+
<CodePreview />
34+
</div>
35+
`;
36+
37+
exports[`Test the CanvasContainer component Matches snapshot 1`] = `
38+
<div
39+
style={
40+
Object {
41+
"backgroundColor": "lightgrey",
42+
"border": "2px Solid grey",
43+
"width": "100%",
44+
}
45+
}
46+
>
47+
<Canvas />
848
</div>
949
`;

__tests__/componentReducer.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,16 @@ describe('Testing componentReducer functionality', function () {
162162
describe('RESET STATE reducer', () => {
163163
it('should reset project to initial state', () => {
164164
const action: Action = {
165-
type: 'RESET STATE'
165+
type: 'RESET STATE',
166+
payload: ''
166167
}
167168
state = reducer(state, action);
168169
// expect default project to have empty string as name
169-
expect(state.name).toEqual('');
170+
expect(state.name).toEqual('TESTNAME');
170171
// expect default project to only have one component in components array
171172
expect(state.components.length).toEqual(1);
173+
// expect lone component to have no children :(
174+
expect(state.components[0].children.length).toEqual(0);
172175
})
173176
})
174177

__tests__/enzyme.test.tsx

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
1-
import { shallow } from 'enzyme';
1+
import { shallow, mount } from 'enzyme';
22
import React from 'react';
33

4-
describe('Enzyme testing suite', () => {
4+
import MainContainer from '../app/src/containers/MainContainer';
5+
import BottomPanel from '../app/src/components/bottom/BottomPanel';
6+
import BottomTabs from '../app/src/components/bottom/BottomTabs';
7+
import CodePreview from '../app/src/components/bottom/CodePreview';
8+
import CanvasContainer from '../app/src/components/main/CanvasContainer';
9+
import Canvas from '../app/src/components/main/Canvas';
510

6-
it('renders snapshots, too', () => {
7-
const wrapper = shallow(<div>
8-
<h1>Hello, Enzyme!</h1>
9-
</div>)
10-
expect(wrapper).toMatchSnapshot()
11+
12+
describe('Test the CanvasContainer component', () => {
13+
const target = shallow(<CanvasContainer />);
14+
it('Matches snapshot', () => {
15+
expect(target).toMatchSnapshot()
16+
})
17+
it('Contains Canvas component', () => {
18+
expect(target.contains(<Canvas />)).toBe(true);
19+
})
20+
})
21+
22+
describe('Test the MainContainer component', () => {
23+
const target = shallow(<MainContainer />);
24+
it('Contains CanvasContainer component', () => {
25+
expect(target.contains(<CanvasContainer />)).toBe(true);
26+
})
27+
it('Contains BottomPanel component', () => {
28+
expect(target.contains(<BottomPanel />)).toBe(true);
1129
})
12-
})
30+
})
31+
32+
describe('Test the BottomTabs component', () => {
33+
const target = shallow(<BottomTabs />);
34+
it('Matches snapshot', () => {
35+
expect(target).toMatchSnapshot()
36+
})
37+
it('Contains a CodePreview component', () => {
38+
expect(target.contains(<CodePreview />)).toBe(true);
39+
})
40+
})
41+

0 commit comments

Comments
 (0)