Skip to content

Commit 8adc420

Browse files
Merge pull request #3 from markusguenther/fix_testing_issues
TASK: Use suppressReactErrorLogging to suppress errors in mocha tests
2 parents 05b24ef + 25e04be commit 8adc420

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

src/components/themr.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
9292
getNamespacedTheme(props) {
9393
const { themeNamespace, theme } = props
9494
if (!themeNamespace) return theme
95-
if (themeNamespace && !theme) throw new Error('Invalid themeNamespace use in for-react-css-themr. ' +
95+
96+
if (themeNamespace && !theme) {
97+
throw new Error('Invalid themeNamespace use in for-react-css-themr. ' +
9698
'themeNamespace prop should be used only with theme prop.')
99+
}
97100

98101
return Object.keys(theme)
99102
.filter(key => key.startsWith(themeNamespace))
@@ -223,6 +226,7 @@ function merge(original = {}, mixin = {}) {
223226
case 'object': {
224227
//can't merge a non-object with an object
225228
throw new Error(`You are merging non-object ${mixinValue} with an object ${key}`)
229+
break
226230
}
227231

228232
case 'undefined': {

test/components/ThemeProvider.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import PropTypes from 'prop-types'
44
import TestUtils from 'react-dom/test-utils'
55
import { ThemeProvider } from '../../src/index'
66

7+
8+
before(function () {
9+
/* eslint-disable no-console */
10+
console.error = function () {}
11+
})
12+
13+
after(function () {
14+
delete console.error
15+
})
16+
717
describe('ThemeProvider', () => {
818
class Child extends Component {
919
render() {

test/setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import raf from './tempPolyfills'
12
import { jsdom } from 'jsdom'
23

34
global.document = jsdom('<!doctype html><html><body></body></html>')

test/tempPolyfills.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const raf = global.requestAnimationFrame = (cb) => {
2+
setTimeout(cb, 0)
3+
}
4+
5+
export default raf

0 commit comments

Comments
 (0)