From 816178d9cb3d49cb5a8ec16d01b0e02be7b5f49b Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sat, 12 Aug 2017 11:12:42 +0100 Subject: [PATCH] Use JSX in tests --- package.json | 16 +++++++++++++++- test/react-jsdom.js | 13 +++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 0e25fbf..a7d8265 100644 --- a/package.json +++ b/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", @@ -34,8 +45,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", diff --git a/test/react-jsdom.js b/test/react-jsdom.js index e31c902..4412cca 100644 --- a/test/react-jsdom.js +++ b/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(
hi
); 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(
hi
); 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(
hi
, window); t.is(elem, window.document.getElementById('root').children[0]); t.is(elem.nodeName, 'DIV'); t.is(elem.textContent, 'hi');