Skip to content

Commit

Permalink
Update the template app to reach 100% coverage
Browse files Browse the repository at this point in the history
And demo jsdom
  • Loading branch information
geowarin committed May 10, 2016
1 parent 96ded89 commit f17e244
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/templates/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"devDependencies": {
"gh-pages": "^0.11.0",
"tarec-plugin-mocha-test": "^1.1.0",
"tarec-plugin-sass": "geowarin/tarec-plugin-sass"
"tarec-plugin-mocha-test": "^1.2.0",
"tarec-plugin-sass": "geowarin/tarec-plugin-sass#master"
}
}
2 changes: 1 addition & 1 deletion lib/templates/app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import React from 'react';
import {render} from 'react-dom';
import App from 'compo/App';

import 'main.scss';
import './main.scss';

render(<App />, document.getElementById('app'));
27 changes: 27 additions & 0 deletions lib/templates/app/test/indexTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import expect from 'expect';
import React from 'react';
import describeWithDom from 'describe-with-dom';
import App from 'compo/App';

describeWithDom('index', () => {

it('should render the page', () => {
createAppDiv();
require('../src/index');
expect(getHtmlBody()).toContain('Hello');
});
});

function createAppDiv() {
const appDiv = getDocument().createElement('div');
appDiv.setAttribute('id', 'app');
getDocument().body.appendChild(appDiv);
}

function getDocument() {
return document.defaultView.document;
}

function getHtmlBody() {
return getDocument().documentElement.outerHTML;
}

0 comments on commit f17e244

Please sign in to comment.