Browse Source

Use JSX in tests

pull/8/head
Luke Childs 7 years ago
parent
commit
0a10dcbd3c
  1. 16
      package.json
  2. 13
      test/react-jsdom.js

16
package.json

@ -8,7 +8,18 @@
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"xo": {
"extends": "xo-lukechilds"
"extends": [
"xo-lukechilds",
"xo-react"
]
},
"ava": {
"babel": {
"presets": [
"@ava/stage-4",
"react"
]
}
},
"repository": {
"type": "git",
@ -32,8 +43,11 @@
},
"devDependencies": {
"ava": "^0.20.0",
"babel-preset-react": "^6.24.1",
"coveralls": "^2.13.1",
"eslint-config-xo-lukechilds": "^1.0.0",
"eslint-config-xo-react": "^0.13.0",
"eslint-plugin-react": "^7.2.0",
"nyc": "^11.0.3",
"react": "^15.6.1",
"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 => {
global.window = 'foo';
global.document = 'bar';
ReactJSDOM.render(
React.createElement('div', {}, 'hi')
);
ReactJSDOM.render(<div>hi</div>);
t.is(global.window, 'foo');
t.is(global.document, 'bar');
});
test('ReactJSDOM renders a React Component', t => {
const elem = ReactJSDOM.render(
React.createElement('div', {}, 'hi')
);
const elem = ReactJSDOM.render(<div>hi</div>);
t.is(elem.nodeName, 'DIV');
t.is(elem.textContent, 'hi');
});
test('ReactJSDOM allows window instance to be passed in', t => {
const window = new Window();
const elem = ReactJSDOM.render(
React.createElement('div', {}, 'hi'),
window
);
const elem = ReactJSDOM.render(<div>hi</div>, window);
t.is(elem, window.document.getElementById('root').children[0]);
t.is(elem.nodeName, 'DIV');
t.is(elem.textContent, 'hi');

Loading…
Cancel
Save