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

Commit

Permalink
tests(day): rewrite tests with RTL (#118)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Marosi <[email protected]>
  • Loading branch information
Uladzimir Havenchyk and Peter Marosi authored Feb 8, 2020
1 parent 8390e71 commit b95b08f
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 339 deletions.
1 change: 1 addition & 0 deletions config/_jest/setupAfterEnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom/extend-expect'
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
coverageDirectory: "./coverage/",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
setupFiles: ["<rootDir>/config/_jest/setupTests.js"],
setupFilesAfterEnv: ['<rootDir>/config/_jest/setupAfterEnv.ts'],
snapshotSerializers: ["enzyme-to-json/serializer"],
testMatch: ["**/__specs__/**/*.tsx"],
testPathIgnorePatterns: ["/node_modules/", "/fixtures/", "/dist"]
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@
"@storybook/addons": "^5.3.12",
"@storybook/react": "^5.3.12",
"@storybook/storybook-deployer": "^2.8.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@types/classnames": "^2.2.9",
"@types/jest": "^24.0.21",
"@types/jest": "^24.0.23",
"@types/react-dom": "^16.9.4",
"@typescript-eslint/eslint-plugin": "^2.6.0",
"@typescript-eslint/parser": "^2.6.0",
Expand Down
158 changes: 4 additions & 154 deletions src/calendar/__specs__/__snapshots__/day_spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,166 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Day #render class variations when prop \`isCurrentMonth\` is \`true\` renders <Day /> 1`] = `
exports[`custom render 1`] = `
<button
className="example-block-class-day is-current_month"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isDisabled\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-disabled"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isHighlighted\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-highlighted"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isMonthNext\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-next_month"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isMonthPrev\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-prev_month"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isNonSelectable\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-not_selectable"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isSelectable\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-selectable"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isSelected\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-selected"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isSelectionEnd\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-end_selection"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isSelectionStart\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-start_selection"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isToday\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-today"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isWeekend\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-weekend"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
</button>
`;

exports[`Day #render class variations when prop \`isWorkday\` is \`true\` renders <Day /> 1`] = `
<button
className="example-block-class-day is-working_day"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
type="button"
value="2015-05-05"
>
5
Custom
</button>
`;

exports[`Day #render renders <Day /> 1`] = `
exports[`default render 1`] = `
<button
className="example-block-class-day"
onClick={[MockFunction]}
onMouseEnter={[MockFunction]}
class="example-block-class-day"
type="button"
value="2015-05-05"
>
Expand Down
Loading

0 comments on commit b95b08f

Please sign in to comment.