Example #1
0
 beforeEach(() => {
   renderer = createRenderer();
   renderer.render(<Counter clicks={ 5 } dispatch={ dispatch } />);
   counter = renderer.getRenderOutput();
 });
describe("TestResults", () => {
  let wrapper;
  const
    renderer = createRenderer();

  beforeEach(() => {
    const testResults = {
        "_class":"hudson.tasks.junit.TestResult",
        "duration":0.008,
        "empty":false,
        "failCount":4,
        "passCount":9,
        "skipCount":3,
        "suites":[
            {"cases":[
                    {"age":0,"className":"failure.TestThisWillFailAbunch","duration":0.002,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest3","skipped":false,"skippedMessage":null,"status":"PASSED","stderr":null,"stdout":null},
                    {"age":0,"className":"failure.TestThisWillFailAbunch","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest4","skipped":false,"skippedMessage":null,"status":"PASSED","stderr":null,"stdout":null},
                    {"age":4,"className":"failure.TestThisWillFailAbunch","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":7,"name":"aFailingTest2","skipped":true,"skippedMessage":null,"status":"SKIPPED","stderr":null,"stdout":null},
                    {"age":4,"className":"failure.TestThisWillFailAbunch","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":7,"name":"aFailingTest3","skipped":true,"skippedMessage":null,"status":"SKIPPED","stderr":null,"stdout":null},
                    {"age":0,"className":"failure.TestThisWillFailAbunch","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aFailingTest4","skipped":false,"skippedMessage":null,"status":"FIXED","stderr":null,"stdout":null},
                    {"age":1,"className":"failure.TestThisWillFailAbunch","duration":0.003,"errorDetails":"<some exception here>","failedSince":7,"name":"aFailingTest","skipped":false,"skippedMessage":null,"status":"FAILED","stderr":null,"stdout":null},
                    {"age":4,"className":"failure.TestThisWillFailAbunch","duration":0.001,"errorDetails":null,"errorStackTrace":null,"failedSince":7,"name":"aNewFailingTest31","skipped":true,"skippedMessage":null,"status":"SKIPPED","stderr":null,"stdout":null}
                ],
                "duration":0.008,
                "id":null,
                "name":"failure.TestThisWillFailAbunch",
                "stderr":null,
                "stdout":null,
                "timestamp":null
            },
            {"cases":[
                    {"age":0,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest2","skipped":false,"skippedMessage":null,"status":"PASSED","stderr":null,"stdout":null},
                    {"age":0,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest3","skipped":false,"skippedMessage":null,"status":"PASSED","stderr":null,"stdout":null},
                    {"age":0,"className":"failure.TestThisWontFail","duration":0,"errorDetails":null,"errorStackTrace":null,"failedSince":0,"name":"aPassingTest4","skipped":false,"skippedMessage":null,"status":"PASSED","stderr":null,"stdout":null},
                    {"age":4,"className":"failure.TestThisWillFailAbunch","duration":0.003,"errorDetails":"<some exception here>","failedSince":7,"name":"aFailingTest","skipped":false,"skippedMessage":null,"status":"FAILED","stderr":null,"stdout":null},
                    {"age":4,"className":"failure.TestThisWillFailAbunch","duration":0.003,"errorDetails":"<some exception here>","failedSince":7,"name":"aFailingTest","skipped":false,"skippedMessage":null,"status":"FAILED","stderr":null,"stdout":null},
                ],
                "duration":0,
                "id":null,
                "name":"failure.TestThisWontFail",
                "stderr":null,
                "stdout":null,
                "timestamp":null
            }
        ]
    };
    wrapper = shallow(<TestResults testResults={testResults} />);
  });

  it("Test fixed included", () => {
      const fixed = wrapper.find('.new-passed .count').text();
      assert.equal(fixed, 1);

      const failed = wrapper.find('.failed .count').text();
      assert.equal(failed, 4);

      const skipped = wrapper.find('.skipped .count').text();
      assert.equal(skipped, 3);

      const newFailed = wrapper.find('.new-failed .count').text();
      assert.equal(newFailed, 1);
  });
});
import { default as React } from 'react'
import { default as TestUtils } from 'react-addons-test-utils'
import { default as expect } from 'expect'
import { Testimonial } from '../src'
import { Flex } from 'reflexbox'

const renderer = TestUtils.createRenderer()

describe('Testimonial', () => {
    let tree

    beforeEach(() => {
        renderer.render(
            <Testimonial
                img="foobar"
                imgSize={100}
                name="foo"
                text="bar"
            />
        )
        tree = renderer.getRenderOutput()
    })

    it('should render', () => {
        expect(tree.type).toEqual(Flex)
    })
})
 it("should render its child as its only output", () => {
   const renderer = TestUtils.createRenderer();
   renderer.render(<Holdable><div></div></Holdable>);
   const output = renderer.getRenderOutput();
   expect(output.type).to.be.equal('div');
 });
const shallowRender = (Component, props) => {
  const renderer = TestUtils.createRenderer();
  renderer.render(<Component {...props}/>);
  return renderer.getRenderOutput();
}
Example #6
0
global.shallowRender = (reactElement) => {
  const shallowRenderer = createRenderer()
  shallowRenderer.render(reactElement)
  return shallowRenderer.getRenderOutput()
}
Example #7
0
 beforeEach(() => {
   renderer = TestUtils.createRenderer();
   renderer.render(<Card name="king-of-hearts" />);
 });
Example #8
0
export function shallowRender(stuff) {
  const renderer = createRenderer();
  renderer.render(stuff);
  return renderer.getRenderOutput();
}
Example #9
0
/**
 * Get the shallow rendered component
 *
 * @param  {Object} component The component to return the output for
 * @param  {Object} props [optional] The components properties
 * @param  {Mixed} ...children [optional] List of children
 * @return {Object} Shallow rendered output
 */
export default function createComponent (component, props = {}, ...children) {
  const shallowRenderer = TestUtils.createRenderer()
  shallowRenderer.render(React.createElement(component, props, children.length > 1 ? children : children[0]))
  return shallowRenderer.getRenderOutput()
}
function shallowRenderPageTitle(title) {
  const renderer = TestUtils.createRenderer()
  renderer.render(<PageTitle title={title}/>)
  return renderer.getRenderOutput()
}
Example #11
0
 beforeEach(() => {
   const renderer = TestUtils.createRenderer();
   renderer.render(<GameScreen onSubmitGuess={submitGuess} />);
   output = renderer.getRenderOutput();
 });
Example #12
0
export function shallowlyRenderedOutput( Component ) {
  const shallowRenderer = TestUtils.createRenderer();
  shallowRenderer.render( Component );

  return shallowRenderer.getRenderOutput();
}
Example #13
0
import ReactTestUtils from "react-addons-test-utils";
import _ from "lodash";

export default {
    React: ReactTestUtils,

    shallowRender(content) {
        let renderer = ReactTestUtils.createRenderer();
        renderer.render(content);
        return renderer;
    },

    shallowRenderUntilDom(content) {
        let renderer = ReactTestUtils.createRenderer();
        renderer.render(content);
        let output = renderer.getRenderOutput();
        // Type for components is their constructor, for DOM elements their name.
        if (_.isFunction(output.type)) {
            return this.shallowRenderUntilDom(output);
        }
        return renderer;
    }
};
Example #14
0
 function renderCounter(isActive,className){
   const renderer = TestUtils.createRenderer();
   renderer.render(<Counter isActive={isActive} />);
   return renderer.getRenderOutput()
     .props.className.includes(className+' counter');
 }
	it('Runs a simple test.', () => {
		var renderer = TestUtils.createRenderer();
		renderer.render(<CommentBox />);
		var renderedCommentBox = renderer.getRenderOutput();
		expect(renderedCommentBox.props.className).to.equal("commentbox")
	});
 before(() => {
     shallowRenderer = TestUtils.createRenderer();
     shallowRenderer.render(<ResponsiveMenu list={listProp} dropdownText={moreText} />);
     shallowRenderer._instance._instance.setState({init: false, visibleCount});
     renderedTree = shallowRenderer.getRenderOutput();
 });
const renderShallow = (element, context = {}) => {
  const renderer = createRenderer();
  renderer.render(element, context);
  const output = renderer.getRenderOutput();
  return { output, renderer };
};
 before(() => {
     shallowRenderer = TestUtils.createRenderer();
     shallowRenderer.render(<ResponsiveMenu list={[]} />);
     renderedTree = shallowRenderer.getRenderOutput();
 });
Example #19
0
 before(function() {
   this.props = { isChecked: true, onClick: Chai.spy() };
   this.renderer = ReactTestUtils.createRenderer();
 });
 before(() => {
     shallowRenderer = TestUtils.createRenderer();
     shallowRenderer.render(<ResponsiveMenu className={customClassName} list={listProp} dropdownText={moreText} />);
     renderedTree = shallowRenderer.getRenderOutput();
 });
Example #21
0
	beforeEach(() => renderer = TestUtils.createRenderer());
 before(() => {
     shallowRenderer = TestUtils.createRenderer();
     shallowRenderer.render(<ResponsiveMenu className="class-name" list={listProp} />);
     renderedTree = shallowRenderer.getRenderOutput();
 });
 it("should pass the correct props to its child", () => {
   const renderer = TestUtils.createRenderer();
   renderer.render(<Holdable><div></div></Holdable>);
   const output = renderer.getRenderOutput();
   expect(output.props).to.have.keys(['__passThrough', 'onMouseDown', 'onTouchStart']);
 });
import test from 'ava';
import { find } from 'lodash';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import About from '../../src/components/About';

const shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(<About />);
const about = shallowRenderer.getRenderOutput();

test('should have a div as container', t => {
  t.is(about.type, 'div');
});

test('should have an h2 tag containing the text "About"', t => {
  t.ok(find(about.props.children, <h2>About</h2>));
});

Example #25
0
 beforeEach(() => {
   renderer = TestUtils.createRenderer();
   intlProvider = new IntlProvider({locale: 'en'}, {});
 });
Example #26
0
function render(component) {
  const renderer = createRenderer();
  renderer.render(component);
  return renderer.getRenderOutput();
}
 function renderLikeCounter(isActive) {
   const renderer = TestUtils.createRenderer();
   renderer.render(<LikeCounter count={5} isActive={isActive} />);
   return renderer.getRenderOutput().props.className.includes('LikeCounter--active');
 }
	it('Runs a second simple test.', () => {
		var renderer = TestUtils.createRenderer();
		renderer.render(<CommentBox />);
		var renderedCommentBox = renderer.getRenderOutput();
		expect(renderedCommentBox.props.children).to.equal("Hello world!");
	});
function shallowRender (component) {
  const renderer = TestUtils.createRenderer();

  renderer.render(component);
  return renderer.getRenderOutput();
}
 beforeEach(function() {
   this.renderer = createRenderer();
   this.tree = this.renderer.render(<TestWithForm />);
 });