From 01b5e5239c730c12ca4c33bf8d9e9ec3573c8277 Mon Sep 17 00:00:00 2001 From: Juan Fabrega Date: Fri, 10 Jul 2020 12:45:00 -0400 Subject: [PATCH] fixing broken builds with svg --- package.json | 1 + rollup.config.js | 2 ++ src/components/TextInput/TextInput.test.jsx | 12 ++++++++++-- yarn.lock | 16 +++++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5858be63f..a5c11d001 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "@storybook/addon-viewport": "^5.3.19", "@storybook/addons": "^5.3.19", "@storybook/react": "^5.3.19", + "@svgr/rollup": "^5.4.0", "@svgr/webpack": "^5.4.0", "@testing-library/jest-dom": "^5.5.0", "@testing-library/react": "^10.0.2", diff --git a/rollup.config.js b/rollup.config.js index 632886114..499479491 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,6 +6,7 @@ import postcss from 'rollup-plugin-postcss'; import copy from 'rollup-plugin-copy'; import cleaner from 'rollup-plugin-cleaner'; import svg from 'rollup-plugin-svg'; +import svgr from '@svgr/rollup'; const packageJson = require('./package.json'); @@ -55,5 +56,6 @@ export default { ], }), svg(), + svgr(), ], }; diff --git a/src/components/TextInput/TextInput.test.jsx b/src/components/TextInput/TextInput.test.jsx index 0407f6451..e9c7ab906 100644 --- a/src/components/TextInput/TextInput.test.jsx +++ b/src/components/TextInput/TextInput.test.jsx @@ -13,7 +13,7 @@ describe('TextInput', () => { */ test('Throws error if required prop "value" is not supplied to component', () => { console.error = jest.fn(); // eslint-disable-line no-console - render( null} />); + render( null} id="myId" />); expect(console.error).toHaveBeenCalledTimes(1); // eslint-disable-line no-console expect(console.error.mock.calls[0][0]) // eslint-disable-line no-console .toContain('Failed prop type: The prop `value`'); @@ -21,12 +21,20 @@ describe('TextInput', () => { test('Throws error if required prop "onChange" is not supplied to component', () => { console.error = jest.fn(); // eslint-disable-line no-console - render(); + render(); expect(console.error).toHaveBeenCalledTimes(1); // eslint-disable-line no-console expect(console.error.mock.calls[0][0]) // eslint-disable-line no-console .toContain('Failed prop type: The prop `onChange`'); }); + test('Throws error if required prop "id" is not supplied to component', () => { + console.error = jest.fn(); // eslint-disable-line no-console + render( null} />); + expect(console.error).toHaveBeenCalledTimes(1); // eslint-disable-line no-console + expect(console.error.mock.calls[0][0]) // eslint-disable-line no-console + .toContain('Failed prop type: The prop `id`'); + }); + test('Throws an error if "type" prop is anything other than allowed values', () => { console.error = jest.fn(); // eslint-disable-line no-console render( null} value="hello" type="notOnTheList" />); diff --git a/yarn.lock b/yarn.lock index eb12afec6..80db91145 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1395,7 +1395,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-react-constant-elements@^7.0.0", "@babel/plugin-transform-react-constant-elements@^7.2.0", "@babel/plugin-transform-react-constant-elements@^7.6.3", "@babel/plugin-transform-react-constant-elements@^7.9.0": +"@babel/plugin-transform-react-constant-elements@^7.0.0", "@babel/plugin-transform-react-constant-elements@^7.2.0", "@babel/plugin-transform-react-constant-elements@^7.6.3", "@babel/plugin-transform-react-constant-elements@^7.7.4", "@babel/plugin-transform-react-constant-elements@^7.9.0": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-constant-elements/-/plugin-transform-react-constant-elements-7.10.4.tgz#0f485260bf1c29012bb973e7e404749eaac12c9e" integrity sha512-cYmQBW1pXrqBte1raMkAulXmi7rjg3VI6ZLg9QIic8Hq7BtYXaWuZSxsr2siOMI6SWwpxjWfnwhTUrd7JlAV7g== @@ -3331,6 +3331,20 @@ merge-deep "^3.0.2" svgo "^1.2.2" +"@svgr/rollup@^5.4.0": + version "5.4.0" + resolved "https://registry.yarnpkg.com/@svgr/rollup/-/rollup-5.4.0.tgz#b1946c8d2c13870397af014a105d40945b7371e5" + integrity sha512-hwYjrTddW6mFU9vwqRr1TULNvxiIxGdIbqrD5J7vtoATSfWazq/2JSnT4BmiH+/4kFXLEtjKuSKoDUotkOIAkg== + dependencies: + "@babel/core" "^7.7.5" + "@babel/plugin-transform-react-constant-elements" "^7.7.4" + "@babel/preset-env" "^7.9.5" + "@babel/preset-react" "^7.9.4" + "@svgr/core" "^5.4.0" + "@svgr/plugin-jsx" "^5.4.0" + "@svgr/plugin-svgo" "^5.4.0" + rollup-pluginutils "^2.8.2" + "@svgr/webpack@^4.0.3": version "4.3.3" resolved "https://registry.yarnpkg.com/@svgr/webpack/-/webpack-4.3.3.tgz#13cc2423bf3dff2d494f16b17eb7eacb86895017"