Skip to content

Commit 84e6bf2

Browse files
committed
fix: more tests included
1 parent b918388 commit 84e6bf2

File tree

8 files changed

+95
-5
lines changed

8 files changed

+95
-5
lines changed

jest.frontend.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable eol-last */
21
const paths = require('./scripts/config/paths');
32

43
module.exports = {
@@ -16,14 +15,16 @@ module.exports = {
1615
],
1716
coverageDirectory: '<rootDir>/frontend-coverage',
1817
coveragePathIgnorePatterns: [
18+
// All type definitions to be excluded
19+
'!*.d.ts',
1920
// All Ignore files should be covered by E2E Tests to get maximum coverage.
2021
'<rootDir>/node_modules',
2122
'<rootDir>/src/client/mobile/metro.config.js',
2223
'<rootDir>/src/client/mobile/babel.config.js',
2324
'<rootDir>/src/client/mobile/__tests__',
2425
'<rootDir>/src/client/web/ssr',
2526
'<rootDir>/src/client/web/server.ts',
26-
'<rootDir>/src/client/web/app/App.e2e-test.ts',
27+
'<rootDir>/src/client/web/app/__tests__/app.e2e-test.ts',
2728
'<rootDir>/src/client/web/app/common/components/doc-gen',
2829
'<rootDir>/src/client/shared/utils/doc-gen.engine.ts',
2930
// Root State

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"@types/prop-types": "15.7.3",
124124
"@types/react": "16.8.20",
125125
"@types/react-transition-group": "2.9.2",
126+
"@testing-library/react-hooks": "3.4.1",
126127
"autoprefixer": "9.8.0",
127128
"babel-eslint": "10.0.2",
128129
"babel-jest": "26.3.0",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
// Library
3+
import { renderHook, act } from '@testing-library/react-hooks';
4+
import useProfilePage from '../profile-model.hooks';
5+
6+
test('should increment counter', () => {
7+
const { result: { current: { profileActions }} } = renderHook(() => useProfilePage({}, {}))
8+
9+
expect(profileActions).toBeDefined();
10+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`ProfileBoxComponent <ProfileBoxComponent /> ChatBox Component renders correctly 1`] = `[Function]`;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Library
2+
import * as React from 'react';
3+
import { ThemeProvider } from '@material-ui/styles';
4+
import { shallow, mount } from 'enzyme';
5+
6+
// Theme
7+
import theme from '../../../styles';
8+
9+
// Web
10+
import ProfileBoxComponent from '../index';
11+
12+
describe('ProfileBoxComponent <ProfileBoxComponent />', () => {
13+
it('ChatBox Component renders correctly', () => {
14+
const ProfileComponentTyped: any = ProfileBoxComponent;
15+
const chatBoxComponent = shallow(
16+
<ThemeProvider theme={theme}>
17+
<ProfileComponentTyped />
18+
</ThemeProvider>
19+
);
20+
21+
// Interaction demo
22+
expect(chatBoxComponent.text()).toEqual(
23+
'<ProfileBox />'
24+
);
25+
26+
// Snapshot demo
27+
expect(shallow).toMatchSnapshot();
28+
});
29+
it('ChatBox Component mounts correctly when props are true', () => {
30+
const ProfileComponentTyped: any = ProfileBoxComponent;
31+
const chatBoxComponent = mount(
32+
<ThemeProvider theme={theme}>
33+
<ProfileComponentTyped />
34+
</ThemeProvider>
35+
);
36+
37+
expect(chatBoxComponent.length).toBeTruthy();
38+
});
39+
});
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
// Library
12
import React from 'react';
23

34
interface ProfileBoxProps {
5+
name?: string;
46
}
57

6-
const ProfileBox: React.SFC<ProfileBoxProps> = (props) => {
8+
const ProfileBox: React.SFC<ProfileBoxProps> = ({ name }) => {
79
return (
8-
<div> Profile Info </div>
10+
<div>
11+
Profile Info
12+
{name}
13+
</div>
914
);
10-
};
15+
};
16+
17+
export default ProfileBox;

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"src/client/**/**/**/*",
5555
"src/client/**/**/**/**/*",
5656
"src/client/**/**/**/**/**/*",
57+
"src/client/shared/state/containers/profile/**/*",
5758
"src/server/**/*",
5859
"src/server/**/**/*",
5960
"src/server/**/**/**/*",

0 commit comments

Comments
 (0)