Skip to content

Issues while testing Bootstrap components. #297

@Nutelac

Description

@Nutelac

I found few issues while testing app with React.addons.TestUtils.

1. ref does not work on ModalTrigger children

code
var Modal = React.createClass({
  render: function(){
    return Bootstrap.ModalTrigger({
      modal: Bootstrap.Modal({
        title: 'modal'
      })
    }, Bootstrap.Button({
      ref: 'button'
    }));
  }
});
test
var modal = TestUtils.renderIntoDocument(Modal(null));
expect(modal.refs.button).toBeTruthy(); // Expected undefined to be truthy.

2. can't change input value via TestUtils.Simulate.change

code
var Input = React.createClass({
  render: function(){
    return Bootstrap.Input({
      ref: 'input',
      type: 'text'
    });
  }
});
test
var input = TestUtils.renderIntoDocument(Input(null));
TestUtils.Simulate.change(input.refs.input.getDOMNode(), {
  target: {
    value: 'foo'
  }
});
expect(input.refs.input.getValue()).toBe('foo'); // Expected: null toBe: 'foo'

Is this expected behaviour or bug? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions