Skip to content

Commit

Permalink
[CHG] Working tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntdb committed Mar 19, 2016
1 parent 4702c81 commit d0c1e96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
"author": "Nate Bailey",
"license": "ISC",
"dependencies": {
"jsonp": "^0.2.0",
"estraverse-fb": "^1.3.1",
"lodash": "^4.6.1",
"node-libs-browser": "^1.0.0",
"node-sass": "^3.4.2",
"react": "^0.14.0",
"react-dom": "^0.14.0",
"react-redux": "^4.0.0",
Expand All @@ -48,20 +49,15 @@
"eslint-config-airbnb": "6.1.0",
"eslint-loader": "^1.0.0",
"eslint-plugin-react": "^4.2.3",
"estraverse-fb": "^1.3.1",
"extend-tape": "^1.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"faucet": "0.0.1",
"file-loader": "^0.8.4",
"node-sass": "^3.2.0",
"react-addons-test-utils": "^0.14.7",
"react-hot-loader": "^1.2.8",
"react-unit": "^1.2.1",
"sass-loader": "^3.2.0",
"scss-lint-loader": "^1.0.1",
"style-loader": "^0.13.0",
"tape": "^4.5.1",
"tape-jsx-equals": "^1.0.0",
"url-loader": "^0.5.6",
"webpack-dev-server": "^1.10.1",
"webpack-notifier": "^1.2.1"
Expand Down
35 changes: 10 additions & 25 deletions tests/components/nameList.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
import React from 'react';
import { createRenderer } from 'react-addons-test-utils';
// import createComponent from 'react-unit';
import TestUtils from 'react-addons-test-utils';
import tape from 'tape';
import addAssertions from 'extend-tape';
import jsxEquals from 'tape-jsx-equals';
const test = addAssertions(tape, {jsxEquals});

// import '../../source/components/nameList/nameList.scss';

// Component to test
import NameList from '../../source/components/nameList/nameList';

test('----- React Component Tests: NameList -----', (t) => {
// Shallow rendering: Render React element only *one* level deep
// const component = createComponent.shallow(<NameList names={['Nate', 'David']} />);
// Tests
tape.test('----- React Component Tests: NameList -----', (t) => {
const renderer = TestUtils.createRenderer();

// Test component props and content
// t.equal(component.props.className, 'default-class', 'ClassName props of component should equal "share"');
// t.equal(component.text, 'share', 'Label props of component should be rendered as Button text "share"');
// Ensure that two names are rendered
renderer.render(<NameList names={['Nate', 'David']} actions={{}} />);
t.equals(renderer.getRenderOutput().props.children[1].length, 2);

// Test rendered output
const renderer = createRenderer();
renderer.render(<NameList names={['Nate', 'David']} />);
const result = renderer.getRenderOutput();
t.jsxEquals(result, (
<div>
<h3>Names!</h3>
<p key="Nate">"Nate"<a>(remove)</a></p>
)}
<a>Add Name</a>
</div>
));
// Ensure that no names are rendered
renderer.render(<NameList names={[]} actions={{}} />);
t.equals(renderer.getRenderOutput().props.children[1].length, 0);

t.end();
});

0 comments on commit d0c1e96

Please sign in to comment.