Skip to content

Instantly share code, notes, and snippets.

@scopevale
Created February 15, 2017 14:50
Show Gist options
  • Select an option

  • Save scopevale/328971593eeafca0c11d229fd0989a8b to your computer and use it in GitHub Desktop.

Select an option

Save scopevale/328971593eeafca0c11d229fd0989a8b to your computer and use it in GitHub Desktop.

Revisions

  1. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions component.js
    Original file line number Diff line number Diff line change
    @@ -3,14 +3,14 @@ import _ from 'lodash';
    import PubSub from 'pubsub-js';

    class Example extends React.Component{
    bar(e){
    console.log('Bar called')
    }
    render() {
    return(
    <button ref="foo" onClick={this.bar}>Hey</button>
    )
    }
    bar(e){
    console.log('Bar called')
    }
    render() {
    return(
    <button ref="foo" onClick={this.bar}>Hey</button>
    )
    }
    };

    export default Example;
  2. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions component.js
    Original file line number Diff line number Diff line change
    @@ -3,14 +3,14 @@ import _ from 'lodash';
    import PubSub from 'pubsub-js';

    class Example extends React.Component{
    bar(e){
    console.log('Bar called')
    }
    render() {
    return(
    <button ref="foo" onClick={this.bar}>Hey</button>
    )
    }
    bar(e){
    console.log('Bar called')
    }
    render() {
    return(
    <button ref="foo" onClick={this.bar}>Hey</button>
    )
    }
    };

    export default Example;
  3. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -6,18 +6,18 @@ var Example = require('./Example.jsx');
    var example;

    beforeEach(function() {
    spyOn(Example.prototype, 'bar');
    example = TestUtils.renderIntoDocument(<Example />);
    spyOn(Example.prototype, 'bar');
    example = TestUtils.renderIntoDocument(<Example />);
    });

    it('should exist', function() {
    expect(TestUtils.isCompositeComponent(example)).toBeTruthy();
    expect(TestUtils.isCompositeComponent(example)).toBeTruthy();
    });

    it('should call bar() onClick', function() {
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    });

    });
  4. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,23 @@
    describe('Example Test', function() {

    var React = require('react/addons');
    var TestUtils = React.addons.TestUtils;
    var Example = require('./Example.jsx');
    var example;
    var React = require('react/addons');
    var TestUtils = React.addons.TestUtils;
    var Example = require('./Example.jsx');
    var example;

    beforeEach(function() {
    spyOn(Example.prototype, 'bar');
    example = TestUtils.renderIntoDocument(<Example />);
    });
    beforeEach(function() {
    spyOn(Example.prototype, 'bar');
    example = TestUtils.renderIntoDocument(<Example />);
    });

    it('should exist', function() {
    expect(TestUtils.isCompositeComponent(example)).toBeTruthy();
    });
    it('should exist', function() {
    expect(TestUtils.isCompositeComponent(example)).toBeTruthy();
    });

    it('should call bar() onClick', function() {
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    });

    it('should call bar() onClick', function() {
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    });

    });
  5. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -15,9 +15,9 @@ describe('Example Test', function() {
    });

    it('should call bar() onClick', function() {
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    });

    });
  6. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -15,11 +15,9 @@ describe('Example Test', function() {
    });

    it('should call bar() onClick', function() {
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    });

    });

    //
    });
  7. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ describe('Example Test', function() {
    var example;

    beforeEach(function() {
    spyOn(Example.prototype, 'bar');
    spyOn(Example.prototype, 'bar');
    example = TestUtils.renderIntoDocument(<Example />);
    });

    @@ -20,4 +20,6 @@ describe('Example Test', function() {
    expect( example.bar ).toHaveBeenCalled();
    });

    });
    });

    //
  8. @alopes alopes revised this gist Sep 17, 2015. No changes.
  9. @alopes alopes revised this gist Sep 17, 2015. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions component.js
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,10 @@ class Example extends React.Component{
    console.log('Bar called')
    }
    render() {
    return(
    <button ref="foo" onClick={this.bar}>Hey</button>
    )
    return(
    <button ref="foo" onClick={this.bar}>Hey</button>
    )
    }
    };


    export default Example;
  10. @alopes alopes created this gist Sep 17, 2015.
    17 changes: 17 additions & 0 deletions component.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import React from 'react';
    import _ from 'lodash';
    import PubSub from 'pubsub-js';

    class Example extends React.Component{
    bar(e){
    console.log('Bar called')
    }
    render() {
    return(
    <button ref="foo" onClick={this.bar}>Hey</button>
    )
    }
    };


    export default Example;
    23 changes: 23 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    describe('Example Test', function() {

    var React = require('react/addons');
    var TestUtils = React.addons.TestUtils;
    var Example = require('./Example.jsx');
    var example;

    beforeEach(function() {
    spyOn(Example.prototype, 'bar');
    example = TestUtils.renderIntoDocument(<Example />);
    });

    it('should exist', function() {
    expect(TestUtils.isCompositeComponent(example)).toBeTruthy();
    });

    it('should call bar() onClick', function() {
    var button = React.findDOMNode(pagination.refs.foo);
    TestUtils.Simulate.click(button);
    expect( example.bar ).toHaveBeenCalled();
    });

    });