From af4f627f8981489eed0ded013541a08ac34cc965 Mon Sep 17 00:00:00 2001 From: Nathan Marks Date: Tue, 27 Aug 2019 12:57:26 -0400 Subject: [PATCH] Get specs working again --- package.json | 14 +- .../Buttons/__tests__/Button.spec.js | 77 +- .../Buttons/__tests__/CircleButton.spec.js | 81 +- .../__snapshots__/Button.spec.js.snap | 1885 +++++----- .../__snapshots__/Checkbox.spec.js.snap | 602 ++- .../__snapshots__/CircleButton.spec.js.snap | 452 ++- .../__snapshots__/Radio.spec.js.snap | 514 ++- .../__snapshots__/Switch.spec.js.snap | 775 ++-- src/components/Forms/ServerError.js | 1 + src/components/Forms/ValidationError.js | 1 + .../Forms/__tests__/DateField.spec.js | 135 +- .../Forms/__tests__/FloatingLabel.spec.js | 41 +- src/components/Forms/__tests__/Form.spec.js | 9 +- .../Forms/__tests__/FormComponent.spec.js | 17 +- .../Forms/__tests__/HelperText.spec.js | 9 +- .../Forms/__tests__/MaskedTextField.spec.js | 187 +- .../Forms/__tests__/PhoneNumberField.spec.js | 155 +- src/components/Forms/__tests__/Select.spec.js | 134 +- .../Forms/__tests__/ServerError.spec.js | 9 +- .../Forms/__tests__/TextField.spec.js | 99 +- .../Forms/__tests__/TextFieldHint.spec.js | 25 +- .../Forms/__tests__/ValidationError.spec.js | 17 +- .../__snapshots__/DateField.spec.js.snap | 1908 +++++----- .../__snapshots__/FloatingLabel.spec.js.snap | 350 +- .../__tests__/__snapshots__/Form.spec.js.snap | 217 +- .../__snapshots__/HelperText.spec.js.snap | 37 +- .../MaskedTextField.spec.js.snap | 1860 +++++---- .../PhoneNumberField.spec.js.snap | 1962 +++++----- .../__snapshots__/Select.spec.js.snap | 3137 ++++++++-------- .../__snapshots__/ServerError.spec.js.snap | 50 +- .../__snapshots__/TextField.spec.js.snap | 712 ++-- .../__snapshots__/TextFieldHint.spec.js.snap | 174 +- .../ValidationError.spec.js.snap | 108 +- src/components/Grid/__tests__/Column.spec.js | 91 +- src/components/Grid/__tests__/Grid.spec.js | 49 +- src/components/Grid/__tests__/Row.spec.js | 75 +- .../__snapshots__/Column.spec.js.snap | 1082 ++++-- .../__tests__/__snapshots__/Grid.spec.js.snap | 495 ++- .../__tests__/__snapshots__/Row.spec.js.snap | 1551 ++++++-- .../__snapshots__/iconSpec.spec.js.snap | 95 +- src/components/Link/__tests__/Link.spec.js | 44 +- .../__tests__/__snapshots__/Link.spec.js.snap | 139 +- .../Loading/__tests__/LoadingBox.spec.js | 65 +- .../__snapshots__/LoadingBox.spec.js.snap | 570 +-- .../Menus/__tests__/DropdownMenu.spec.js | 37 +- src/components/Menus/__tests__/Menu.spec.js | 35 +- .../__snapshots__/DropdownMenu.spec.js.snap | 626 ++-- .../__tests__/__snapshots__/Menu.spec.js.snap | 309 +- .../__tests__/NavigationPills.spec.js | 155 +- .../__snapshots__/NavigationPill.spec.js.snap | 345 +- .../NavigationPills.spec.js.snap | 3308 +++++++---------- .../__tests__/__snapshots__/Pill.spec.js.snap | 114 +- .../Portal/__tests__/LegacyPorta.spec.js | 13 +- .../__snapshots__/LegacyPorta.spec.js.snap | 14 +- .../__snapshots__/iconSpec.spec.js.snap | 1 - .../ScrollTrack/__tests__/ScrollTrack.spec.js | 319 +- .../__snapshots__/ScrollTrack.spec.js.snap | 1009 ++--- .../Tooltip/__tests__/Tooltip.spec.js | 14 +- .../__snapshots__/Tooltip.spec.js.snap | 25 +- .../Transitions/__tests__/Fade.spec.js | 17 +- .../Transitions/__tests__/Grow.spec.js | 31 +- .../Transitions/__tests__/Slide.spec.js | 17 +- .../__tests__/__snapshots__/Fade.spec.js.snap | 62 +- .../__tests__/__snapshots__/Grow.spec.js.snap | 74 +- .../__snapshots__/Slide.spec.js.snap | 90 +- .../Typography/__tests__/Text.spec.js | 16 +- .../__tests__/__snapshots__/Text.spec.js.snap | 825 ++-- src/utils/__tests__/omit.spec.js | 12 +- yarn.lock | 265 +- 69 files changed, 14069 insertions(+), 13674 deletions(-) diff --git a/package.json b/package.json index 1e251b10..645ff358 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "release:build": "babel-node scripts/release/build_release.js", "release:verifyBuild": "babel-node scripts/release/verify_build.js", "release:publish": "babel-node scripts/release/publish_release.js", - "lint": "eslint src --ext .js,.jsx --ignore-pattern '*.spec.js'", + "lint": "eslint src --ext .js,.jsx,.ts,.tsx --ignore-pattern '*.spec.js'", "lint:fix": "npm run lint -- --fix", "test:lint": "npm run lint -- --quiet", "start": "webpack --progress --watch --config webpack.config.js", "styleguide": "styleguidist server", "styleguide:build": "styleguidist build && node scripts/moveBuildAssets.js", - "test:watch": "npm test -- --watch --bail", + "test:watch": "jest --watch --bail", "test": "jest --silent && npm run test:lint", "test:ci": "jest --silent --maxWorkers=2 && npm run test:lint", "test:generate-coverage-report": "codecov" @@ -64,20 +64,21 @@ "babel-loader": "^8.0.0", "codecov": "^3.1.0", "coveralls": "^3.0.2", - "enzyme": "^3.3.0", - "enzyme-adapter-react-16": "^1.1.1", - "enzyme-to-json": "^3.3.3", + "enzyme": "^3.10.0", + "enzyme-adapter-react-16": "^1.14.0", + "enzyme-to-json": "^3.4.0", "eslint": "5.16.0", "eslint-import-resolver-webpack": "0.11.0", "fs-extra": "^5.0.0", "glob": "7.1.4", "jest": "^24.8.0", + "jest-emotion": "10.0.14", "prettier": "1.16.4", "prompt": "^1.0.0", "react": "16.4.2", "react-dom": "16.4.2", "react-styleguidist": "9.0.9", - "react-test-renderer": "^16.2.0", + "react-test-renderer": "16.4.2", "react-transition-group": "^2.2.1", "sinon": "^2.3.8", "typescript": "^3.2.2", @@ -112,6 +113,7 @@ "transform": { "^.+\\.js$": "babel-jest" }, + "snapshotSerializers": ["jest-emotion"], "coverageDirectory": "./coverage/", "testURL": "http://localhost", "collectCoverage": true, diff --git a/src/components/Buttons/__tests__/Button.spec.js b/src/components/Buttons/__tests__/Button.spec.js index 737d5fc6..3a732a74 100644 --- a/src/components/Buttons/__tests__/Button.spec.js +++ b/src/components/Buttons/__tests__/Button.spec.js @@ -1,6 +1,5 @@ import React from 'react' import renderer from 'react-test-renderer' -import { StyleRoot } from 'radium' import { mount } from 'enzyme' import { spy } from 'sinon' import Icon from '../../Icon/Icon' @@ -16,13 +15,7 @@ describe('Button', () => { ] testCases.forEach(props => { - const tree = renderer - .create( - - - - ) - .toJSON() + const tree = renderer.create().toJSON() expect(tree).toMatchSnapshot() }) }) @@ -36,13 +29,7 @@ describe('Button', () => { ] testCases.forEach(props => { - const tree = renderer - .create( - - - - ) - .toJSON() + const tree = renderer.create().toJSON() expect(tree).toMatchSnapshot() }) }) @@ -50,11 +37,9 @@ describe('Button', () => { it('renders with inverted colors', () => { const tree = renderer .create( - - - + ) .toJSON() expect(tree).toMatchSnapshot() @@ -69,13 +54,7 @@ describe('Button', () => { ] testCases.forEach(props => { - const tree = renderer - .create( - - - - ) - .toJSON() + const tree = renderer.create().toJSON() expect(tree).toMatchSnapshot() }) }) @@ -83,11 +62,9 @@ describe('Button', () => { it('applies the elementAttributes prop correctly', () => { const tree = renderer .create( - - - + ) .toJSON() expect(tree).toMatchSnapshot() @@ -96,13 +73,11 @@ describe('Button', () => { it('fires the onClick prop', () => { const onClick = spy() const wrapper = mount( - -
- -
-
+
+ +
) wrapper.find('button').simulate('click') @@ -113,11 +88,9 @@ describe('Button', () => { it('renders correctly when disabled', () => { const tree = renderer .create( - - - + ) .toJSON() expect(tree).toMatchSnapshot() @@ -126,11 +99,9 @@ describe('Button', () => { it('does not fire the onClick prop when disabled', () => { const onClick = spy() const wrapper = mount( - - - + ) wrapper.find('button').simulate('click') @@ -140,11 +111,9 @@ describe('Button', () => { it('can render as a link if an href is provided', () => { const tree = renderer.create( - - - + ) expect(tree).toMatchSnapshot() }) diff --git a/src/components/Buttons/__tests__/CircleButton.spec.js b/src/components/Buttons/__tests__/CircleButton.spec.js index 7c5029e3..0b7da9eb 100644 --- a/src/components/Buttons/__tests__/CircleButton.spec.js +++ b/src/components/Buttons/__tests__/CircleButton.spec.js @@ -1,6 +1,5 @@ import React from 'react' import renderer from 'react-test-renderer' -import { StyleRoot } from 'radium' import { mount } from 'enzyme' import { spy } from 'sinon' import Icon from '../../Icon/Icon' @@ -9,11 +8,9 @@ import CircleButton from '../CircleButton' it('renders basic CircleButton correctly', () => { const tree = renderer .create( - -
- 1 -
-
+
+ 1 +
) .toJSON() expect(tree).toMatchSnapshot() @@ -22,13 +19,11 @@ it('renders basic CircleButton correctly', () => { it('renders CircleButton with Icon correctly', () => { const tree = renderer .create( - -
- - - -
-
+
+ + + +
) .toJSON() expect(tree).toMatchSnapshot() @@ -37,19 +32,17 @@ it('renders CircleButton with Icon correctly', () => { it('renders CircleButton with passed style prop correctly', () => { const tree = renderer .create( - -
- - 1 - -
-
+
+ + 1 + +
) .toJSON() expect(tree).toMatchSnapshot() @@ -58,11 +51,9 @@ it('renders CircleButton with passed style prop correctly', () => { it('renders CircleButton with passed ariaLabel correctly', () => { const tree = renderer .create( - -
- 1 -
-
+
+ 1 +
) .toJSON() expect(tree).toMatchSnapshot() @@ -71,11 +62,9 @@ it('renders CircleButton with passed ariaLabel correctly', () => { it('renders CircleButton with passed disabled prop correctly', () => { const tree = renderer .create( - -
- 1 -
-
+
+ 1 +
) .toJSON() expect(tree).toMatchSnapshot() @@ -84,11 +73,9 @@ it('renders CircleButton with passed disabled prop correctly', () => { it('calls onClick callback correctly', () => { const onClick = spy() const CButton = mount( - -
- 1 -
-
+
+ 1 +
) const button = CButton.find('button').first() @@ -99,13 +86,11 @@ it('calls onClick callback correctly', () => { it('does not call onClick when disabled prop is true', () => { const onClick = spy() const CButton = mount( - -
- - 1 - -
-
+
+ + 1 + +
) const button = CButton.find('button').first() diff --git a/src/components/Buttons/__tests__/__snapshots__/Button.spec.js.snap b/src/components/Buttons/__tests__/__snapshots__/Button.spec.js.snap index 45e80ad3..7fb9652f 100644 --- a/src/components/Buttons/__tests__/__snapshots__/Button.spec.js.snap +++ b/src/components/Buttons/__tests__/__snapshots__/Button.spec.js.snap @@ -1,979 +1,1048 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Button applies the elementAttributes prop correctly 1`] = ` -
- -