From e492d6c78772da34348137f494be8896530acdf1 Mon Sep 17 00:00:00 2001 From: Michael Lancaster Date: Tue, 17 Apr 2018 14:04:37 -0700 Subject: [PATCH] fix: jest config and merge conflicts --- components/badge/badge.test.tsx | 55 ----------------- jest.config.js | 50 ++++++++++++++++ jest.config.json | 11 ---- package.json | 60 +------------------ packages/badge/components/badgeButton.tsx | 11 +++- packages/badge/stories/badge.stories.tsx | 7 +++ .../__snapshots__/badgeButton.test.tsx.snap | 14 ++--- 7 files changed, 77 insertions(+), 131 deletions(-) delete mode 100644 components/badge/badge.test.tsx create mode 100644 jest.config.js delete mode 100644 jest.config.json diff --git a/components/badge/badge.test.tsx b/components/badge/badge.test.tsx deleted file mode 100644 index e64a40ff7..000000000 --- a/components/badge/badge.test.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import React from "react"; -import Badge from "../badge"; -import renderer from "react-test-renderer"; - -const StringComponent = (): JSX.Element => { - return string; -}; - -describe("Badge", () => { - it("default", () => { - expect(renderer.create(default).toJSON()).toMatchSnapshot(); - }); - - it("success", () => { - expect( - renderer.create(success).toJSON() - ).toMatchSnapshot(); - }); - - it("primary", () => { - expect( - renderer.create(primary).toJSON() - ).toMatchSnapshot(); - }); - - it("danger", () => { - expect( - renderer.create(danger).toJSON() - ).toMatchSnapshot(); - }); - - it("warning", () => { - expect( - renderer.create(warning).toJSON() - ).toMatchSnapshot(); - }); - - it("outline", () => { - expect( - renderer.create(outline).toJSON() - ).toMatchSnapshot(); - }); - - it("accept jsx as children", () => { - expect( - renderer - .create( - - - - ) - .toJSON() - ).toMatchSnapshot(); - }); -}); diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 000000000..010230ed9 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,50 @@ +module.exports = { + "rootDir": ".", + "testPathIgnorePatterns": [ + "/node_modules/", + "/dist/", + "scripts" + ], + "coverageReporters": [ + "json", + "text" + ], + "projects": [ + { + "displayName": "Jest", + "roots": [ + "packages" + ], + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "jsx", + "json", + "node" + ], + "setupTestFrameworkScriptFile": "/testHelper/setupTests.ts", + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "transform": { + "^.+\\.tsx?$": "ts-jest" + } + }, + { + "displayName": "Prettier", + "runner": "jest-runner-prettier", + "moduleFileExtensions": [ + "js", + "jsx", + "json", + "ts", + "tsx" + ], + "testMatch": [ + "/packages/**/*.{ts|tsx}", + "tslint.json", + "tsconfig.json", + "tsconfig.dist.json", + ] + } + ] +} diff --git a/jest.config.json b/jest.config.json deleted file mode 100644 index ffed9159c..000000000 --- a/jest.config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rootDir": ".", - "roots": ["packages"], - "transform": { - "^.+\\.tsx?$": "ts-jest" - }, - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", - "moduleFileExtensions": ["js", "jsx", "json", "ts", "tsx"], - "testPathIgnorePatterns": ["/node_modules/"], - "setupTestFrameworkScriptFile": "/testHelper/setupTests.ts" -} diff --git a/package.json b/package.json index 072a25142..90bf333a5 100644 --- a/package.json +++ b/package.json @@ -30,63 +30,9 @@ "test": "jest", "test:watch": "jest --watch" }, - "files": ["dist"], - "jest": { - "coverageReporters": [ - "json", - "text" - ], - "projects": [{ - "displayName": "Jest", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "jsx", - "json", - "node" - ], - "setupTestFrameworkScriptFile": "/testHelper/setupTests.ts", - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", - "transform": { - "^.+\\.tsx?$": "ts-jest" - }, - "roots": [ - "components" - ] - }, { - "displayName": "Prettier", - "runner": "jest-runner-prettier", - "moduleFileExtensions": [ - "js", - "jsx", - "json", - "ts", - "tsx", - "css", - "less", - "scss", - "graphql", - "md", - "markdown" - ], - "testMatch": [ - "**/*.js", - "**/*.jsx", - "tslint.json", - "tsconfig.json", - "tsconfig.dist.json", - "components/**/*.ts", - "components/**/*.tsx", - "**/*.css", - "**/*.less", - "**/*.scss", - "**/*.graphql", - "**/*.md", - "**/*.markdown" - ] - }] - }, + "files": [ + "dist" + ], "typings": "dist/components/index", "dependencies": { "emotion": "9.0.2", diff --git a/packages/badge/components/badgeButton.tsx b/packages/badge/components/badgeButton.tsx index ca11181be..e885b3d23 100644 --- a/packages/badge/components/badgeButton.tsx +++ b/packages/badge/components/badgeButton.tsx @@ -1,3 +1,4 @@ +import { css } from "emotion"; import * as React from "react"; import { badge as badgeButton } from "../style"; @@ -27,7 +28,15 @@ export class BadgeButton extends React.PureComponent { public render() { const { appearance, children, onClick, tabIndex } = this.props; - const props = { onClick, tabIndex, className: badgeButton(appearance) }; + const props = { + onClick, + tabIndex, + className: css` + outline: none; + cursor: pointer; + ${badgeButton(appearance)}; + ` + }; return ; } diff --git a/packages/badge/stories/badge.stories.tsx b/packages/badge/stories/badge.stories.tsx index ea3b3604f..4505adb04 100644 --- a/packages/badge/stories/badge.stories.tsx +++ b/packages/badge/stories/badge.stories.tsx @@ -31,4 +31,11 @@ storiesOf("Badge", module) "Outline", "Outline badges for when we want the density of the badge to be lighter e.g. when next to data in a table cell", () => Outline + ) + .addWithInfo( + "Button", + "Button badges for when we want add click event", + () => ( + badge button + ) ); diff --git a/packages/badge/tests/__snapshots__/badgeButton.test.tsx.snap b/packages/badge/tests/__snapshots__/badgeButton.test.tsx.snap index 97d619348..b97b46c1b 100644 --- a/packages/badge/tests/__snapshots__/badgeButton.test.tsx.snap +++ b/packages/badge/tests/__snapshots__/badgeButton.test.tsx.snap @@ -2,7 +2,7 @@ exports[`BadgeButton accept jsx as children 1`] = `