How to use the react-dom/test-utils.scryRenderedDOMComponentsWithClass function in react-dom

To help you get started, weโ€™ve selected a few react-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github department-of-veterans-affairs / vets-website / test / edu-benefits / 1995 / config / applicantInformation.unit.spec.jsx View on Github external
const errors = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'usa-input-error-message');
    expect(errors.find(input => input.id.includes('root_veteranSocialSecurityNumber'))).to.be.ok;

    // Check no-SSN box
    const noSSNBox = ReactTestUtils.scryRenderedDOMComponentsWithTag(form, 'input')
      .find(input => input.id === 'root_view:noSSN');
    ReactTestUtils.Simulate.change(noSSNBox,
      {
        target: {
          checked: true
        }
      });

    // No error is shown for empty SSN input; error is shown for empty file number input
    const newErrors = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'usa-input-error-message');
    expect(newErrors.find(input => input.id.includes('root_veteranSocialSecurityNumber'))).not.to.be.ok;
    expect(newErrors.find(input => input.id.includes('root_vaFileNumber'))).to.be.ok;
  });
  it('should submit with no errors with all required fields filled in', () => {
github jedireza / aqua / test / client / pages / account / settings / password-form.js View on Github external
lab.test('it renders with success state', (done) => {

        const props = ObjectAssign({}, defaultProps, {
            showSaveSuccess: true
        });
        const FormEl = React.createElement(Form, props);
        const form = ReactTestUtils.renderIntoDocument(FormEl);
        const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'alert-success');

        Code.expect(alerts).to.have.length(1);

        done();
    });
github plougsgaard / react-timeout / test / timing.jsx View on Github external
it('can cancel 500 callbacks by unmounting why not', (done) => {
    const container = document.createElement('div')
    const newRendering = render(, container)
    const b = scryRenderedDOMComponentsWithClass(newRendering, 'test5')[0]

    let i = 0
    for (i = 0; i < 500; i++) {
      Simulate.click(b)
    }

    setTimeout(() => unmountComponentAtNode(container), 10)

    setTimeout(() => {
      expect(window.uglyMutableLeakyVariableTest5).to.equal(0)
      setTimeout(done)
    }, 500)
  })
github plougsgaard / react-timeout / test / timing.jsx View on Github external
it('eventually mutates leaky variable', (done) => {
    const b = scryRenderedDOMComponentsWithClass(rendering, 'test3')[0]
    Simulate.click(b)

    expect(window.uglyMutableLeakyVariableTest3).to.equal('none')

    setTimeout(() => {
      expect(window.uglyMutableLeakyVariableTest3).to.equal('test3')
      setTimeout(done)
    }, 500)
  })
github negomi / react-burger-menu / test / menuFactory.spec.js View on Github external
it('accepts an optional crossClassName', () => {
      component = TestUtils.renderIntoDocument(<menu>);
      const bars = TestUtils.scryRenderedDOMComponentsWithClass(component, 'bm-cross');
      expect(bars[0].classList.toString()).to.contain('custom-class');
    });
  });</menu>
github yang-wei / rd3 / tests / piechart-tests.js View on Github external
it('doesnt show inner labels if not specified', function() {
    var piechart = TestUtils.renderIntoDocument(
      
    );
    
    var labels = TestUtils.scryRenderedDOMComponentsWithClass(piechart, 'rd3-piechart-value');
    expect(labels.length).to.equal(0);    
  });
github jedireza / aqua / test / client / pages / main / login / home / index.js View on Github external
lab.test('it renders with error state', (done) => {

        const root = ReactTestUtils.renderIntoDocument(RootEl);

        Store.dispatch({
            type: Constants.LOGIN_RESPONSE,
            err: new Error('sorry pal'),
            response: {
                message: 'major fail'
            }
        });

        const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, 'alert-danger');

        Code.expect(alerts).to.have.length(1);

        done();
    });
});
github georgeOsdDev / react-draggable-tab / test / components / Tabs_spec.js View on Github external
expect(rdTabBefore[0].className).contain('mySpecialTabBefore');
      expect(rdTabBefore[1].className).not.contain('mySpecialTabBefore');

      let rdTabAfter = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabAfter');
      expect(rdTabAfter[0].className).contain('mySpecialTabAfter');
      expect(rdTabAfter[1].className).not.contain('mySpecialTabAfter');

      let rdTabTitle = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabTitle');
      expect(rdTabTitle[0].className).contain('mySpecialTabTitle');
      expect(rdTabTitle[1].className).not.contain('mySpecialTabTitle');

      let rdTabBeforeTitle = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabBeforeTitle');
      expect(rdTabBeforeTitle[0].className).contain('mySpecialTabBeforeTitle');
      expect(rdTabBeforeTitle[1].className).not.contain('mySpecialTabBeforeTitle');

      let rdTabAfterTitle = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabAfterTitle');
      expect(rdTabAfterTitle[0].className).contain('mySpecialTabAfterTitle');
      expect(rdTabAfterTitle[1].className).not.contain('mySpecialTabAfterTitle');

      let rdTabActive = ReactTestUtils.findRenderedDOMComponentWithClass(component, 'rdTabActive');
      expect(rdTabActive.className).contain('mySpecialTabActive');

      let rdTabCloseIcon = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabCloseIcon');
      expect(rdTabCloseIcon[0].className).contain('mySpecialTabCloseIcon');
      expect(rdTabCloseIcon[1].className).not.contain('mySpecialTabCloseIcon');

    });
github rawls238 / react-experiments / __tests__ / testNamespace.js View on Github external
expect(getLogLength()).toEqual(1);

    const experimentComponent2 = TestUtils.renderIntoDocument(
      
        
      
    );

    expect(TestUtils.scryRenderedDOMComponentsWithClass(
      experimentComponent2,
      'Variation B'
    ).length).toBe(0);

    //renders the correct variation
    expect(TestUtils.scryRenderedDOMComponentsWithClass(
      experimentComponent2,
      'default'
    ).length).toBe(1);

    expect(getLogLength()).toEqual(1);
  });
github Foundry376 / Mailspring / app / internal_packages / composer-emoji / specs / emoji-composer-extension-spec.jsx View on Github external
waitsFor(() => {
        return (
          ReactTestUtils.scryRenderedDOMComponentsWithClass(this.component, 'emoji-option').length >
          0
        );
      });
      runs(() => {