Beispiel #1
0
        return test_utils.renderWithRouter(Login).then(comp => {
          let username = comp.refs.username;
          let password = comp.refs.password;
          let submit = comp.refs.submit;

          TestUtils.Simulate.change(username, { target: { value: 'dominataa' }});
          TestUtils.Simulate.change(password, { target: { value: 'abcdef' }});
          TestUtils.Simulate.click(submit);
          assert(comp.submit.calledWith('dominataa', 'abcdef'), 'submit should be called with username and password');
        });
    it('toggels state.show_options', () => {

      simple_select = TestUtils.renderIntoDocument(<SimpleSelect />)
      TestUtils.Simulate.click(simple_select.refs.simpleSelectValue)
      expect(simple_select.state.show_options).to.be.true

      simple_select = TestUtils.renderIntoDocument(<SimpleSelect />)
      simple_select.setState({show_options: true})
      TestUtils.Simulate.click(simple_select.refs.simpleSelectValue)
      expect(simple_select.state.show_options).to.be.false
    })
Beispiel #3
0
 it('Calls onChange when changed', (done) => {
   const doneOp = () => done();
   const instance = renderIntoDocument(
     <Checkbox onChange={doneOp} />
   );
   Simulate.change(getInputNode(instance));
 });
 it('expects the value to change to the option that was clicked', () => {
   let simple_select = TestUtils.renderIntoDocument(<SimpleSelect options={['foo','bar']} value={'foo'}/>)
   simple_select.setState({show_options: true})
   let options = TestUtils.scryRenderedDOMComponentsWithClass(simple_select, 'simple-select-option');
   TestUtils.Simulate.click(options[1])
   expect(simple_select.state.value).to.equal('bar')
 });
 it('sets the value to null when empty option is clicked', () => {
   let simple_select = TestUtils.renderIntoDocument(<SimpleSelect includeBlank={true} options={['foo','bar']} value={'foo'}/>)
   simple_select.setState({show_options: true})
   let options = TestUtils.scryRenderedDOMComponentsWithClass(simple_select, 'simple-select-option');
   TestUtils.Simulate.click(options[0])
   expect(simple_select.state.value).to.be.null
 });
 it('Should call onClick callback', function (done) {
   let doneOp = function () {
     done();
   };
   let instance = ReactTestUtils.renderIntoDocument(
     <Button onClick={doneOp}>
       Title
     </Button>
   );
   ReactTestUtils.Simulate.click(React.findDOMNode(instance));
 });
 it('Should not call `onSelect` when item disabled and is selected', function () {
   function handleSelect() {
     throw new Error('onSelect should not be called');
   }
   let instance = ReactTestUtils.renderIntoDocument(
     <NavItem disabled={true} onSelect={handleSelect}>
       <span>Item content</span>
     </NavItem>
   );
   ReactTestUtils.Simulate.click(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'span'));
 });
 it('Should call `onSelect` with target attribute', function (done) {
   function handleSelect(key, href, target) {
     assert.equal(target, '_blank');
     done();
   }
   let instance = ReactTestUtils.renderIntoDocument(
     <NavItem onSelect={handleSelect} target="_blank">
       <span>Item content</span>
     </NavItem>
   );
   ReactTestUtils.Simulate.click(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'span'));
 });
 it('Should call `onSelect` when item is selected', function (done) {
   function handleSelect(key) {
     assert.equal(key, '2');
     done();
   }
   let instance = ReactTestUtils.renderIntoDocument(
     <NavItem eventKey='2' onSelect={handleSelect}>
       <span>Item content</span>
     </NavItem>
   );
   ReactTestUtils.Simulate.click(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'span'));
 });
  it('Should obey onSelect handler', () => {
    function handleSelect(eventKey, e) {
      if (e.target.className.indexOf('ignoreme') > -1) {
        e.selected = false;
      }
    }

    let header = (
      <div>
        <span className="clickme">Click me</span>
        <span className="ignoreme">Ignore me</span>
      </div>
    );

    let instance = ReactTestUtils.renderIntoDocument(
      <PanelGroup accordion onSelect={handleSelect}>
        <Panel eventKey="1" header={header}>
          <div>Panel body</div>
        </Panel>
      </PanelGroup>
    );

    let panel = ReactTestUtils.findRenderedComponentWithType(instance, Panel);

    assert.notOk(panel.state.expanded);

    ReactTestUtils.Simulate.click(
      ReactTestUtils.findRenderedDOMComponentWithClass(panel, 'ignoreme')
    );

    assert.notOk(panel.state.expanded);

    ReactTestUtils.Simulate.click(
      ReactTestUtils.findRenderedDOMComponentWithClass(panel, 'clickme')
    );

    assert.ok(panel.state.expanded);
  });
 it('Should pass ModalTrigger onBlur prop to child', function() {
   let called = false;
   let callback = function() {
     called = true;
   };
   let instance = ReactTestUtils.renderIntoDocument(
     <ModalTrigger modal={<div>test</div>} onBlur={callback}>
       <button>button</button>
     </ModalTrigger>
   );
   let modalTrigger = instance.getDOMNode();
   ReactTestUtils.Simulate.blur(modalTrigger);
   assert.equal(called, true);
 });
  it('Should call `onClick` with target attribute', function (done) {
    function handleClick(key, href, target) {
      assert.equal(target, '_blank');
      done();
    }
    instance = ReactTestUtils.renderIntoDocument(
      <SplitButton title="Title" dropdownTitle="New title" href="/some/unique-thing/" target="_blank" onClick={handleClick}>
        <MenuItem eventKey="1">MenuItem 1 content</MenuItem>
      </SplitButton>
    );

    let buttons = ReactTestUtils.scryRenderedComponentsWithType(instance, Button);
    ReactTestUtils.Simulate.click(ReactTestUtils.findRenderedDOMComponentWithTag(buttons[0], 'a'));
  });
  it('should display a menu when the input is focused', () => {
    const instance = ReactTestUtils.renderIntoDocument(
      <Typeahead options={[]} />
    );
    const inputNode = ReactTestUtils.findRenderedDOMComponentWithClass(
      instance,
      'bootstrap-typeahead-input-main'
    );
    ReactTestUtils.Simulate.focus(inputNode);

    const menuNode = ReactTestUtils.findRenderedDOMComponentWithClass(
      instance,
      'bootstrap-typeahead-menu'
    );

    expect(menuNode).to.exist;
  });
  it('should not display a menu on focus when `minLength = 1`', () => {
    const instance = ReactTestUtils.renderIntoDocument(
      <Typeahead minLength={1} options={[]} />
    );
    const inputNode = ReactTestUtils.findRenderedDOMComponentWithClass(
      instance,
      'bootstrap-typeahead-input-main'
    );
    ReactTestUtils.Simulate.focus(inputNode);

    const menuNode = ReactTestUtils.scryRenderedDOMComponentsWithClass(
      instance,
      'bootstrap-typeahead-menu'
    );

    expect(menuNode.length).to.equal(0);
  });
  it('Should not collapse panel by bubbling onSelect callback', () => {
    let instance = ReactTestUtils.renderIntoDocument(
      <PanelGroup accordion>
        <Panel>
          <input type="text" className="changeme" />
        </Panel>
      </PanelGroup>
    );

    let panel = ReactTestUtils.findRenderedComponentWithType(instance, Panel);

    assert.notOk(panel.state.collapsing);

    ReactTestUtils.Simulate.select(
      ReactTestUtils.findRenderedDOMComponentWithClass(panel, 'changeme')
    );

    assert.notOk(panel.state.collapsing);
  });
 it('expect this.state.show_options to be true when value is clicked', () => {
   let simple_select = TestUtils.renderIntoDocument(<SimpleSelect />)
   TestUtils.Simulate.click(simple_select.refs.simpleSelectValue)
   expect(simple_select.state.show_options).to.be.true
 });
 beforeEach(() => {
   simple_select = TestUtils.renderIntoDocument(<SimpleSelect options={options_object} includeBlank={true} />)
   simple_select.setState({show_options: true})
   let options = TestUtils.scryRenderedDOMComponentsWithClass(simple_select, 'simple-select-option');
   TestUtils.Simulate.click(options[0])
 });
 it('hitting enter should call commit of cellMetaData only once', () => {
   let editor = TestUtils.findRenderedComponentWithType(component, SimpleTextEditor);
   TestUtils.Simulate.keyDown(editor.getInputNode(), {key: 'Enter'});
   expect(cellMetaData.onCommit).toHaveBeenCalled();
   expect(cellMetaData.onCommit.callCount).toEqual(1);
 });
 it('fires the onChange prop when the value changes', () => {
   TestUtils.Simulate.click(options[1]);
   expect(callback.called).to.be.true;
 })
 it('does not fire the onChange prop when the value does not change', () => {
   TestUtils.Simulate.click(options[0]);
   expect(callback.called).to.be.false;
 })
 it('responds to click events', () => {
   TestUtils.Simulate.click(pieNode);
   expect(clickSpy).to.have.been.called();
 });
 it('will allow the user to close it', function(){
   TestUtils.Simulate.click(alertDOM.childNodes[0], {});
   expect(alertDOM.className).toEqual(hiddenClassName);
   expect(alertDOM.childNodes[1].textContent).toEqual('');
 });
Beispiel #23
0
 it('can facilitate removal of files and update the preview', () => {
   // click the Remove link
   TestUtils.Simulate.click(removeLink);
   expect(ul.class).not.toBeDefined();
 });