Skip to content

Commit

Permalink
Beef up tests for SFCs and optimize npm test scripts
Browse files Browse the repository at this point in the history
Add mount context tests for SFC

Add mount contains test for SFC

Add mount find tests for SFC

Add mount findWhere tests for class components

Add mount setProps tests for SFC

Add mount setContext tests for SFC

Add mount simulate test for SFC

Add mount text tests for SFC

Add mount render, html, children tests for SFC

Add mount attachTo tests for SFC

Add SFC tests for utils

Add SFC tests for debug

Add SFC tests for ShallowTraversal

Update npm scripts
  • Loading branch information
griffinmichl committed May 16, 2016
1 parent 49f30b2 commit 511493b
Show file tree
Hide file tree
Showing 5 changed files with 627 additions and 16 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
"prepublish": "npm run clean && npm run build",
"preversion": "npm run clean && npm run check",
"postversion": "git push && git push --tags && npm run clean && npm run docs:publish",
"pretest": "npm run lint",
"version": "npm run build",
"clean": "rimraf build",
"lint": "eslint src/** test/**",
"check": "npm run lint && npm run test:all",
"build": "babel src --out-dir build",
"test": "npm run lint && npm run test:only",
"test": "npm run test:only",
"test:only": "mocha --require withDom.js --compilers js:babel-core/register --recursive test/*.js --reporter dot",
"test:single": "mocha --require withDom.js --compilers js:babel-core/register --watch --reporter dot",
"test:watch": "mocha --require withDom.js --compilers js:babel-core/register --recursive test/*.js --watch --reporter dot",
"test:env": "sh ./example-test.sh",
"test:all": "npm run react:13 && npm test && npm run react:14 && npm test && npm run react:15 && npm test",
"test:all": "npm run react:13 && npm run test:only && npm run react:14 && npm run test:only && npm run react:15 && npm run test:only",
"react:clean": "rimraf node_modules/react node_modules/react-dom node_modules/react-addons-test-utils",
"react:13": "npm run react:clean && npm i react@0.13",
"react:14": "npm run react:clean && npm i react@0.14 react-dom@0.14 react-addons-test-utils@0.14",
Expand Down
110 changes: 109 additions & 1 deletion test/Debug-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
debugNode,
} from '../src/Debug';
import { mount } from '../src/';
import { describeWithDOM, itIf } from './_helpers';
import {
describeWithDOM,
describeIf,
itIf,
} from './_helpers';
import { REACT013 } from '../src/version';

describe('debug', () => {
Expand Down Expand Up @@ -315,5 +319,109 @@ describe('debug', () => {
</Bar>`);

});

describeIf(!REACT013, 'stateless function components', () => {
it('renders basic debug of mounted components', () => {
const Foo = () => (
<div className="foo">
<span>Foo</span>
</div>
);
expect(mount(<Foo id="2" />).debug()).to.eql(
`<Foo id="2">
<div className="foo">
<span>
Foo
</span>
</div>
</Foo>`);
});

it('renders debug of compositional components', () => {
const Foo = () => (
<div className="foo">
<span>Foo</span>
</div>
);
const Bar = () => (
<div className="bar">
<span>Non-Foo</span>
<Foo baz="bax" />
</div>
);
expect(mount(<Bar id="2" />).debug()).to.eql(
`<Bar id="2">
<div className="bar">
<span>
Non-Foo
</span>
<Foo baz="bax">
<div className="foo">
<span>
Foo
</span>
</div>
</Foo>
</div>
</Bar>`);
});

it('renders a subtree of a mounted tree', () => {
const Foo = () => (
<div className="foo">
<span>Foo</span>
</div>
);
const Bar = () => (
<div className="bar">
<span>Non-Foo</span>
<Foo baz="bax" />
</div>
);
expect(mount(<Bar id="2" />).find(Foo).debug()).to.eql(
`<Foo baz="bax">
<div className="foo">
<span>
Foo
</span>
</div>
</Foo>`);
});

it('renders passed children properly', () => {
const Foo = (props) => (
<div className="foo">
<span>From Foo</span>
{props.children}
</div>
);

const Bar = () => (
<div className="bar">
<Foo baz="bax">
<span>From Bar</span>
</Foo>
</div>
);

expect(mount(<Bar id="2" />).debug()).to.eql(
`<Bar id="2">
<div className="bar">
<Foo baz="bax">
<div className="foo">
<span>
From Foo
</span>
<span>
From Bar
</span>
</div>
</Foo>
</div>
</Bar>`);

});

});
});
});
Loading

0 comments on commit 511493b

Please sign in to comment.