Skip to content

Commit 09ec9cf

Browse files
author
Markus Günther
committed
TASK: Add jsdom handling from old setup.js
The jsdom initialisation was part of the removed setup.js. So now we add this to the beforeEach test.
1 parent 8b7ba27 commit 09ec9cf

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

test/components/ThemeProvider.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ import React, { Component } from 'react'
22
import PropTypes from 'prop-types'
33
import TestUtils from 'react-dom/test-utils'
44
import { ThemeProvider } from '../../src/index'
5+
import { jsdom } from 'jsdom'
56

7+
const documentDom = jsdom('<!doctype html><html><body></body></html>')
68
beforeEach(() => {
9+
global.document = documentDom
10+
global.window = document.defaultView
11+
global.navigator = global.window.navigator
12+
713
jest.spyOn(console, 'error')
814
global.console.error.mockImplementation(() => {})
915
})

test/components/themr.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import React, { Children, Component } from 'react'
22
import PropTypes from 'prop-types'
3+
import { jsdom } from 'jsdom'
34
import TestUtils from 'react-dom/test-utils'
45
import sinon from 'sinon'
56
import { render } from 'react-dom'
67
import shallowEqual from 'fbjs/lib/shallowEqual'
78
import { themr, themeable } from '../../src/index'
89

10+
const documentDom = jsdom('<!doctype html><html><body></body></html>')
11+
912
describe('Themr decorator function', () => {
1013
class Passthrough extends Component {
1114
render() {
@@ -36,6 +39,10 @@ describe('Themr decorator function', () => {
3639
}
3740

3841
beforeEach(() => {
42+
global.document = documentDom
43+
global.window = document.defaultView
44+
global.navigator = global.window.navigator
45+
3946
jest.spyOn(console, 'error')
4047
global.console.error.mockImplementation(() => {})
4148
})

0 commit comments

Comments
 (0)