Skip to content

Commit

Permalink
Coverage on es6 files
Browse files Browse the repository at this point in the history
  • Loading branch information
pradel committed Aug 4, 2016
1 parent 0ed8b00 commit 42df2e0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"main": "lib/portal.js",
"scripts": {
"build": "babel src --out-dir lib",
"build:test": "babel test --out-dir lib-test",
"lint": "eslint src",
"test": "npm run lint && npm run build && npm run test:src",
"test-travis": "npm run build && npm run build:test && npm run lint && npm run test-travis:src",
"test-travis": "npm run lint && npm run build && npm run test-travis:src",
"test:src": "mocha --compilers js:babel-core/register --require ./test/setup.js ./test/portal.js",
"test-travis:src": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec ./lib-test",
"test-travis:src": "./node_modules/.bin/babel-node ./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha -- --require ./test/setup.js ./test/portal.js",
"publish-please": "publish-please",
"prepublish": "publish-please guard"
},
Expand All @@ -31,6 +30,7 @@
"devDependencies": {
"babel-cli": "^6.11.4",
"babel-core": "^6.11.4",
"babel-istanbul": "^0.11.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"chai": "^3.5.0",
Expand Down
26 changes: 24 additions & 2 deletions test/portal.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow, mount } from 'enzyme';
import { assert } from 'chai';
import Portal from '../lib/portal';
import Portal from '../src/portal';

describe('Portal', () => {
it('should not be in current react three', () => {
const element = <p>Hello</p>;
const wrapper = shallow(<Portal>{element}</Portal>);
assert.equal(wrapper.find(element).length, 0);
wrapper.unmount();
});

it('should be rendered in a new react three', () => {
const element = <p>Hello</p>;
const wrapper = shallow(<Portal>{element}</Portal>);
assert.match(document.documentElement.innerHTML, /Hello/);
wrapper.unmount();
});

it('should update props', () => {
const element = <p>Hello</p>;
const wrapper = mount(<Portal>{element}</Portal>);
assert.match(document.documentElement.innerHTML, /Hello/);
const prop = <p>Hi</p>;
wrapper.setProps({ children: prop });
assert.match(document.documentElement.innerHTML, /Hi/);
wrapper.unmount();
});

it('should unmount', () => {
const element = <p>Hello</p>;
const wrapper = shallow(<Portal>{element}</Portal>);
assert.match(document.documentElement.innerHTML, /Hello/);
wrapper.unmount();
assert.notMatch(document.documentElement.innerHTML, /Hello/);
});
});

0 comments on commit 42df2e0

Please sign in to comment.