Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Commit

Permalink
Merge pull request #89 from davezuko/deprecate/local-test-utils
Browse files Browse the repository at this point in the history
deprecate(utils/test): remove render helper utils
  • Loading branch information
David Zukowski committed Sep 15, 2015
2 parents f5bbfea + c4789c0 commit 85af88a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
9 changes: 0 additions & 9 deletions src/utils/test.js

This file was deleted.

28 changes: 17 additions & 11 deletions src/views/HomeView.spec.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { HomeView } from './HomeView';
import { shallowRender } from 'utils/test';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { HomeView } from './HomeView';

function renderWith (props = {}) {
function shallowRender (component) {
const renderer = TestUtils.createRenderer();

renderer.render(component);
return renderer.getRenderOutput();
}

function renderWithProps (props = {}) {
return TestUtils.renderIntoDocument(<HomeView {...props} />);
}

function shallowRenderWith (props = {}) {
function shallowRenderWithProps (props = {}) {
return shallowRender(<HomeView {...props} />)
}

describe('(View) Home', function () {
let component, rendered;

beforeEach(function () {
component = shallowRenderWith();
rendered = renderWith();
component = shallowRenderWithProps();
rendered = renderWithProps();
});

it('(Meta) Should have a test that works with Chai expectations.', function () {
Expand All @@ -43,7 +49,7 @@ describe('(View) Home', function () {

it('Should render props.counter at the end of the sample counter <h2>.', function () {
const h2 = TestUtils.findRenderedDOMComponentWithTag(
renderWith({ counter : 5 }), 'h2'
renderWithProps({ counter : 5 }), 'h2'
);

expect(h2).to.exist;
Expand All @@ -60,7 +66,7 @@ describe('(View) Home', function () {
it('Should call props.dispatch when "Increment" button is clicked.', function () {
const dispatch = sinon.spy();
const btn = TestUtils.findRenderedDOMComponentWithTag(
renderWith({ dispatch }), 'button'
renderWithProps({ dispatch }), 'button'
);

dispatch.should.have.not.been.called;
Expand All @@ -71,7 +77,7 @@ describe('(View) Home', function () {
it('Should dispatch an action with type "COUNTER_INCREMENT" when "Increment" button is clicked.', function () {
const dispatch = sinon.spy();
const btn = TestUtils.findRenderedDOMComponentWithTag(
renderWith({ dispatch }), 'button'
renderWithProps({ dispatch }), 'button'
);

dispatch.should.have.not.been.called;
Expand Down

0 comments on commit 85af88a

Please sign in to comment.