-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |