Browse Source

Use JSX in tests

react-dom-peer-dep
Luke Childs 7 years ago
parent
commit
816178d9cb
  1. 16
      package.json
  2. 13
      test/react-jsdom.js

16
package.json

@ -8,7 +8,18 @@
"coverage": "nyc report --reporter=text-lcov | coveralls" "coverage": "nyc report --reporter=text-lcov | coveralls"
}, },
"xo": { "xo": {
"extends": "xo-lukechilds" "extends": [
"xo-lukechilds",
"xo-react"
]
},
"ava": {
"babel": {
"presets": [
"@ava/stage-4",
"react"
]
}
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -34,8 +45,11 @@
}, },
"devDependencies": { "devDependencies": {
"ava": "^0.20.0", "ava": "^0.20.0",
"babel-preset-react": "^6.24.1",
"coveralls": "^2.13.1", "coveralls": "^2.13.1",
"eslint-config-xo-lukechilds": "^1.0.0", "eslint-config-xo-lukechilds": "^1.0.0",
"eslint-config-xo-react": "^0.13.0",
"eslint-plugin-react": "^7.2.0",
"nyc": "^11.0.3", "nyc": "^11.0.3",
"react": "^15.6.1", "react": "^15.6.1",
"this": "^1.0.2", "this": "^1.0.2",

13
test/react-jsdom.js

@ -10,27 +10,20 @@ test('ReactJSDOM is a object', t => {
test('ReactJSDOM cleans up globals', t => { test('ReactJSDOM cleans up globals', t => {
global.window = 'foo'; global.window = 'foo';
global.document = 'bar'; global.document = 'bar';
ReactJSDOM.render( ReactJSDOM.render(<div>hi</div>);
React.createElement('div', {}, 'hi')
);
t.is(global.window, 'foo'); t.is(global.window, 'foo');
t.is(global.document, 'bar'); t.is(global.document, 'bar');
}); });
test('ReactJSDOM renders a React Component', t => { test('ReactJSDOM renders a React Component', t => {
const elem = ReactJSDOM.render( const elem = ReactJSDOM.render(<div>hi</div>);
React.createElement('div', {}, 'hi')
);
t.is(elem.nodeName, 'DIV'); t.is(elem.nodeName, 'DIV');
t.is(elem.textContent, 'hi'); t.is(elem.textContent, 'hi');
}); });
test('ReactJSDOM allows window instance to be passed in', t => { test('ReactJSDOM allows window instance to be passed in', t => {
const window = new Window(); const window = new Window();
const elem = ReactJSDOM.render( const elem = ReactJSDOM.render(<div>hi</div>, window);
React.createElement('div', {}, 'hi'),
window
);
t.is(elem, window.document.getElementById('root').children[0]); t.is(elem, window.document.getElementById('root').children[0]);
t.is(elem.nodeName, 'DIV'); t.is(elem.nodeName, 'DIV');
t.is(elem.textContent, 'hi'); t.is(elem.textContent, 'hi');

Loading…
Cancel
Save