Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
chore: add initial test
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed Oct 4, 2020
1 parent 157ca67 commit e45a352
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
23 changes: 21 additions & 2 deletions web/package.json
Expand Up @@ -10,7 +10,7 @@
"start": "./node_modules/webpack/bin/webpack.js --watch --mode development",
"build": "./node_modules/webpack/bin/webpack.js --mode production",
"lint": "eslint src",
"test": "npm run lint && jest --passWithNoTests"
"test": "npm run lint && jest"
},
"dependencies": {
"connected-react-router": "^6.8.0",
Expand Down Expand Up @@ -56,8 +56,27 @@
"webpack-dev-server": "^3.11.0"
},
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.{js,jsx}",
"!**/coverage/**",
"!**/dist/**",
"!**/node_modules/**",
"!**/tests/**",
"!**/src/components/swipecard/**",
"!webpack.config.js"
],
"coverageReporters": ["lcov", "text-summary"],
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 0,
"lines": 0,
"statements": 0
}
},
"setupFiles": [
"<rootDir>/src/tests/testSetup.js"
"<rootDir>/tests/test-setup.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
Expand Down
33 changes: 33 additions & 0 deletions web/tests/components/__snapshots__/header-btn.test.js.snap
@@ -0,0 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Header button should be rendered correctly when closed 1`] = `
<HeaderBtn
handleClick={[MockFunction]}
isOpen={false}
>
<button
className="header-btn header-btn-closed"
onClick={[Function]}
>
<div
className="header-btn-arrow header-btn-arrow-right"
/>
</button>
</HeaderBtn>
`;

exports[`Header button should be rendered correctly when open 1`] = `
<HeaderBtn
handleClick={[MockFunction]}
isOpen={true}
>
<button
className="header-btn header-btn-open"
onClick={[Function]}
>
<div
className="header-btn-arrow"
/>
</button>
</HeaderBtn>
`;
18 changes: 18 additions & 0 deletions web/tests/components/header-btn.test.js
@@ -0,0 +1,18 @@
import { mount } from 'enzyme';
import React from 'react';

import HeaderBtn from '../../src/components/header-btn';

const clickHandler = jest.fn();

test('Header button should be rendered correctly when closed', () => {
let component = mount(<HeaderBtn isOpen={false} handleClick={clickHandler} />);

expect(component).toMatchSnapshot();
});

test('Header button should be rendered correctly when open', () => {
let component = mount(<HeaderBtn isOpen={true} handleClick={clickHandler} />);

expect(component).toMatchSnapshot();
});
File renamed without changes.
File renamed without changes.

0 comments on commit e45a352

Please sign in to comment.