Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 2b12ff7

Browse files
committed
Unit testing with Jest
1 parent e770be2 commit 2b12ff7

File tree

11 files changed

+2133
-626
lines changed

11 files changed

+2133
-626
lines changed

Diff for: .eslintignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
dist
1+
__coverage__
2+
dist
3+
node_modules

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
__coverage__
12
.build-info
23
.sass-cache
34
dist

Diff for: __tests__/.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["topcoder-react-utils/config/babel/node-ssr"]
3+
}

Diff for: __tests__/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../node_modules/topcoder-react-utils/config/eslint/jest.json"
3+
}

Diff for: __tests__/index.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import iface from '../src';
2+
3+
test('Package exports expected interface', () => {
4+
expect(iface).toHaveProperty('Avatar');
5+
6+
/* components/buttons */
7+
expect(iface).toHaveProperty('Button');
8+
expect(iface).toHaveProperty('DangerButton');
9+
expect(iface).toHaveProperty('GhostButton');
10+
expect(iface).toHaveProperty('PrimaryButton');
11+
expect(iface).toHaveProperty('SecondaryButton');
12+
13+
/* components/tags */
14+
expect(iface).toHaveProperty('Tag');
15+
expect(iface).toHaveProperty('DataScienceTrackTag');
16+
expect(iface).toHaveProperty('DataScienceTrackEventTag');
17+
expect(iface).toHaveProperty('DesignTrackTag');
18+
expect(iface).toHaveProperty('DesignTrackEventTag');
19+
expect(iface).toHaveProperty('DevelopmentTrackTag');
20+
expect(iface).toHaveProperty('DevelopmentTrackEventTag');
21+
});

Diff for: __tests__/shared/components/Avatar.jsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Avatar from 'components/Avatar';
2+
import React from 'react';
3+
import { snapshot } from 'topcoder-react-utils/jest-utils';
4+
5+
test('Snapshots', () => {
6+
snapshot(<Avatar />);
7+
});
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Snapshots 1`] = `
4+
<svg
5+
className="style__avatar___3QhkH"
6+
height="141"
7+
viewBox="0 0 141 141"
8+
width="141"
9+
xmlns="http://www.w3.org/2000/svg"
10+
xmlnsXlink="http://www.w3.org/1999/xlink"
11+
>
12+
<title>
13+
ico-user-default
14+
</title>
15+
<defs>
16+
<rect
17+
height="140"
18+
id="a"
19+
rx="306"
20+
width="140"
21+
x=".8"
22+
y=".5"
23+
/>
24+
</defs>
25+
<g
26+
fill="none"
27+
fillRule="evenodd"
28+
>
29+
<mask
30+
fill="#fff"
31+
id="b"
32+
>
33+
<use
34+
xlinkHref="#a"
35+
/>
36+
</mask>
37+
<use
38+
fill="#F0F0F0"
39+
xlinkHref="#a"
40+
/>
41+
<path
42+
d="M118 137.143c0 4.345-3.501 7.857-7.833 7.857H31.833C27.51 145 24 141.488 24 137.143c0-15.714 15.142-30.376 30.62-36.174-8.937-5.54-14.953-15.377-14.953-26.683v-7.857C39.667 49.072 53.697 35 71 35c17.304 0 31.333 14.072 31.333 31.429v7.857c0 11.306-6.016 21.143-14.946 26.683 15.471 5.798 30.613 20.46 30.613 36.174z"
43+
fill="#A3A3AE"
44+
mask="url(#b)"
45+
opacity=".2"
46+
stroke="#A3A3AE"
47+
strokeWidth="3"
48+
/>
49+
</g>
50+
</svg>
51+
`;

Diff for: config/jest/default.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const config = require('topcoder-react-utils/config/jest/default');
2+
3+
module.exports = config;

Diff for: config/jest/setup.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('topcoder-react-utils/config/jest/setup');

0 commit comments

Comments
 (0)