diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/src/components/themr.js b/src/components/themr.js index ef6d091..829f7e4 100644 --- a/src/components/themr.js +++ b/src/components/themr.js @@ -92,8 +92,11 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) => getNamespacedTheme(props) { const { themeNamespace, theme } = props if (!themeNamespace) return theme - if (themeNamespace && !theme) throw new Error('Invalid themeNamespace use in for-react-css-themr. ' + + + if (themeNamespace && !theme) { + throw new Error('Invalid themeNamespace use in for-react-css-themr. ' + 'themeNamespace prop should be used only with theme prop.') + } return Object.keys(theme) .filter(key => key.startsWith(themeNamespace)) @@ -223,6 +226,7 @@ function merge(original = {}, mixin = {}) { case 'object': { //can't merge a non-object with an object throw new Error(`You are merging non-object ${mixinValue} with an object ${key}`) + break } case 'undefined': { diff --git a/test/components/ThemeProvider.spec.js b/test/components/ThemeProvider.spec.js index 478400e..da4df5c 100644 --- a/test/components/ThemeProvider.spec.js +++ b/test/components/ThemeProvider.spec.js @@ -4,6 +4,16 @@ import PropTypes from 'prop-types' import TestUtils from 'react-dom/test-utils' import { ThemeProvider } from '../../src/index' + +before(function () { + /* eslint-disable no-console */ + console.error = function () {} +}) + +after(function () { + delete console.error +}) + describe('ThemeProvider', () => { class Child extends Component { render() { diff --git a/test/setup.js b/test/setup.js index c2e0f0c..d890537 100644 --- a/test/setup.js +++ b/test/setup.js @@ -1,3 +1,4 @@ +import raf from './tempPolyfills' import { jsdom } from 'jsdom' global.document = jsdom('') diff --git a/test/tempPolyfills.js b/test/tempPolyfills.js new file mode 100644 index 0000000..7110b0a --- /dev/null +++ b/test/tempPolyfills.js @@ -0,0 +1,5 @@ +const raf = global.requestAnimationFrame = (cb) => { + setTimeout(cb, 0) +} + +export default raf