Skip to content

TASK: Use suppressReactErrorLogging to suppress errors in mocha tests #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
6 changes: 5 additions & 1 deletion src/components/themr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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': {
Expand Down
10 changes: 10 additions & 0 deletions test/components/ThemeProvider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions test/setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import raf from './tempPolyfills'
import { jsdom } from 'jsdom'

global.document = jsdom('<!doctype html><html><body></body></html>')
Expand Down
5 changes: 5 additions & 0 deletions test/tempPolyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const raf = global.requestAnimationFrame = (cb) => {
setTimeout(cb, 0)
}

export default raf