diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d7ba96be0..2e67f3bd11 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,7 @@ jobs: command: yarn prettier - run: name: Unit Tests - command: yarn test --maxWorkers=4 + command: yarn test --strict --maxWorkers=4 - run: name: Report coverage command: bash <(curl -s https://codecov.io/bash) diff --git a/CHANGELOG.md b/CHANGELOG.md index b11a0f3e62..805932d460 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Fixes +- Prevent blind props forwarding if `Input`'s wrapper is defined as React element @kuzhelov ([#453](https://github.com/stardust-ui/react/pull/453)) + ### Features - Add all default size Teams icons processed & ready to be consumed by Stardust as needed @codepretty ([#478](https://github.com/stardust-ui/react/pull/478)) - Add `Tree` Component @priyankar205 ([#479] @@ -27,13 +30,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [Compare changes](https://github.com/stardust-ui/react/compare/v0.12.1...v0.13.0) ### BREAKING CHANGES -- rename `Transition` component to `Animation`, and `animationName` property to `name` @mnajdova ([#505](https://github.com/stardust-ui/react/pull/505)) +- Rename `Transition` component to `Animation`, and `animationName` property to `name` @mnajdova ([#505](https://github.com/stardust-ui/react/pull/505)) ### Fixes -- do not enforce yarn 1.10 via engines @Bugaa92 ([#531](https://github.com/stardust-ui/react/pull/531)) +- Do not enforce yarn 1.10 via engines @Bugaa92 ([#531](https://github.com/stardust-ui/react/pull/531)) ### Documentation -- add `Animations` guide as part of the `Theming` docs page @mnajdova ([#505](https://github.com/stardust-ui/react/pull/505)) +- Add `Animations` guide as part of the `Theming` docs page @mnajdova ([#505](https://github.com/stardust-ui/react/pull/505)) ## [v0.12.1](https://github.com/stardust-ui/react/tree/v0.12.1) (2018-11-26) diff --git a/build/gulp/tasks/test-unit.ts b/build/gulp/tasks/test-unit.ts index bfc2e28c3c..8b04106d74 100644 --- a/build/gulp/tasks/test-unit.ts +++ b/build/gulp/tasks/test-unit.ts @@ -9,10 +9,12 @@ import sh from '../sh' const jest = ({ watch = false } = {}) => cb => { process.env.NODE_ENV = 'test' + const jestConfigFileName = `jest.config.${argv.strict ? 'strict' : 'common'}.js` + // in watch mode jest never exits // let the gulp task complete to prevent blocking subsequent tasks const command = [ - 'jest --coverage', + `jest --config ./test/${jestConfigFileName} --coverage`, watch && '--watchAll', argv.runInBand && '--runInBand', argv.maxWorkers && `--maxWorkers=${argv.maxWorkers}`, diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000000..0725dd6398 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,3 @@ +const commonConfig = require('./test/jest.config.common') + +module.exports = commonConfig diff --git a/package.json b/package.json index e402f5440f..f9e2b6e46f 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "build": "gulp build", "build:docs": "gulp --series dll build:docs", "build:dist": "gulp --series dll build:dist", - "ci": "yarn lint && yarn prettier && yarn test", + "ci": "yarn lint && yarn prettier && yarn test --strict", "predeploy:docs": "cross-env NODE_ENV=production yarn build:docs", "deploy:docs": "gulp deploy:docs", "lint": "tslint -t stylish -p .", @@ -56,29 +56,6 @@ "url": "https://github.com/stardust-ui/react/issues" }, "homepage": "https://github.com/stardust-ui/react#readme", - "jest": { - "coverageDirectory": "./coverage/", - "coverageReporters": [ - "json", - "lcov" - ], - "testRegex": "/test/.*-test\\.tsx?$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "setupTestFrameworkScriptFile": "/test/setup.ts", - "transform": { - "^.+\\.(ts|tsx)$": "ts-jest" - }, - "moduleNameMapper": { - "docs/(.*)$": "/docs/$1", - "src/(.*)$": "/src/$1", - "test/(.*)$": "/test/$1" - } - }, "dependencies": { "classnames": "^2.2.5", "fela": "^6.1.7", diff --git a/src/components/Input/Input.tsx b/src/components/Input/Input.tsx index f322d0feef..338a57121d 100644 --- a/src/components/Input/Input.tsx +++ b/src/components/Input/Input.tsx @@ -181,8 +181,13 @@ class Input extends AutoControlledComponent, InputState> })} ), - styles: styles.root, ...rest, + + // do not pass Stardust 'styles' prop + // in case if React Element was used to define 'wrapper' + ...(!React.isValidElement(wrapper) && { + styles: styles.root, + }), }, overrideProps: { as: (wrapper && (wrapper as any).as) || ElementType, diff --git a/test/jest.config.common.js b/test/jest.config.common.js new file mode 100644 index 0000000000..89cfcabae1 --- /dev/null +++ b/test/jest.config.common.js @@ -0,0 +1,23 @@ +module.exports = { + coverageDirectory: "./coverage/", + coverageReporters: [ + 'json', + 'lcov' + ], + testRegex: '/test/.*-test\\.tsx?$', + moduleFileExtensions: [ + 'ts', + 'tsx', + 'js', + 'json' + ], + setupTestFrameworkScriptFile: `${__dirname}/setup.common.ts`, + transform: { + '^.+\\.(ts|tsx)$': 'ts-jest' + }, + moduleNameMapper: { + 'docs/(.*)$': `${__dirname}/../docs/$1`, + 'src/(.*)$': `${__dirname}/../src/$1`, + 'test/(.*)$': `${__dirname}/../test/$1` + } +} diff --git a/test/jest.config.strict.js b/test/jest.config.strict.js new file mode 100644 index 0000000000..e80c3d6512 --- /dev/null +++ b/test/jest.config.strict.js @@ -0,0 +1,6 @@ +const commonConfig = require('./jest.config.common') + +module.exports = Object.assign({}, + commonConfig, + { setupTestFrameworkScriptFile: `${__dirname}/setup.strict.ts` } +) diff --git a/test/setup.ts b/test/setup.common.ts similarity index 100% rename from test/setup.ts rename to test/setup.common.ts diff --git a/test/setup.strict.ts b/test/setup.strict.ts new file mode 100644 index 0000000000..734602f89f --- /dev/null +++ b/test/setup.strict.ts @@ -0,0 +1,17 @@ +/** + * Setup (Strict) + * This is the bootstrap code that is run before any tests, utils, mocks in 'strict' mode. + */ +require('./setup.common') + +jest.spyOn(console, 'log') +jest.spyOn(console, 'info') +jest.spyOn(console, 'warn') +jest.spyOn(console, 'error') + +afterAll(() => { + expect(console.log).not.toHaveBeenCalled() + expect(console.info).not.toHaveBeenCalled() + expect(console.warn).not.toHaveBeenCalled() + expect(console.error).not.toHaveBeenCalled() +})