How to use react-dom - 10 common examples

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
// Use Array find() for nodes with 'view:' in the id, and check for ok (truthiness) instead of null since
    // not found nodes will return undefined instead of null

    // VA file number input is not visible; error is shown for empty SSN input
    const inputs = ReactTestUtils.scryRenderedDOMComponentsWithTag(form, 'input');
    expect(inputs.find(input => input.id === 'root_veteranSocialSecurityNumber')).to.be.ok;
    expect(inputs.find(input => input.id === 'root_vaFileNumber')).not.to.be.ok;

    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 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 apiaryio / attributes-kit / test / fixturesComparision.js View on Github external
}

        // to minim
        const minimNamespace = new Namespace();
        dataStructureElements = minimNamespace.fromRefract(dataStructureElements);

        renderedElement = React.createElement(Attributes, {
          element: dataStructureElements.first,
          dataStructures: dataStructureElements,
          collapseByDefault: false,
          maxInheritanceDepth: undefined,
          includedProperties: 'show',
          inheritedProperties: 'show',
        });

        htmlString = ReactDomServer.renderToStaticMarkup(renderedElement);
      });
github jinzhubaofu / ei / test / client / spec / util / connect.spec.js View on Github external
},
            // actions
            {
                hello
            }
        );

        const context = {
            store: {
                name: 'ludafa'
            },
            dispatch
        };


        const result = ReactDOM.renderToStaticMarkup(
            
                
            
        );

        expect(result).toBe('<div>I am ludafa and I am 18</div>');


    });
github vector-im / riot-web / test / app-tests / loading.js View on Github external
async function completeLogin(matrixChat) {
        // we expect a single  component
        const login = ReactTestUtils.findRenderedComponentWithType(
            matrixChat, sdk.getComponent('structures.auth.Login'));

        // When we switch to the login component, it'll hit the login endpoint
        // for proof of life and to get flows. We'll only give it one option.
        httpBackend.when('GET', '/login')
            .respond(200, {"flows": [{"type": "m.login.password"}]});
        httpBackend.flush(); // We already would have tried the GET /login request

        // Give the component some time to finish processing the login flows before
        // continuing.
        await sleep(100);

        httpBackend.when('POST', '/login').check(function(req) {
            expect(req.data.type).toEqual('m.login.password');
            expect(req.data.identifier.type).toEqual('m.id.user');
            expect(req.data.identifier.user).toEqual('user');
github yang-wei / rd3 / tests / legendchart-tests.js View on Github external
var legend = TestUtils.renderIntoDocument(
       
    );

    var legendWithTitle = TestUtils.renderIntoDocument(
       
    );

    // Verify there is no heading element
    var noTitleHeadings = TestUtils.scryRenderedDOMComponentsWithTag(
      legend, 'h4');
    expect(noTitleHeadings).to.have.length(0);

    // Verify there is a heading element
    var titleHeadings = TestUtils.scryRenderedDOMComponentsWithTag(
      legendWithTitle, 'h4');
    expect(titleHeadings).to.have.length(1);
  });
});
github atom / github / lib / atom-items / file-patch-pane-item.js View on Github external
destroy() {
    // TODO: is this right?
    this.emitter.emit('did-destroy');
    this.emitter.dispose();
    ReactDom.unmountComponentAtNode(this.getElement());
  }
}
github reubn / tabla / src / static.js View on Github external
export default ({atomicNumber, chunks}) =&gt; {
  history.push(`/${atomicNumber||''}`)
  linkHistoryToStore(store)

  const styleTagString = collectStyles()

  // HACK: Pass FullElement down for render
  global.fullElementHack = atomicNumber ? new FullElement(atomicNumber, fullElements[atomicNumber]) : {}

  const renderedAppString = renderToString()
  const stateScriptString = `window.dryState = ${JSON.stringify(store.getState()).replace(/)

  console.log('⚡️', atomicNumber)
  return ` ${documentString}`
}
github notablemind / notablemind / bin / server.js View on Github external
BakedDoc.load(data, (err, doc, file) =&gt; {
    if (err) return done(err)
    console.log('loaded data. rendering')

    var embedData = JSON.stringify(data).replace(/) // doc
    console.log('rendered')

    done(null, `
      
        
        <title>${data[0].content} | Notablemind</title>
github unfoldingWord / translationCore / src / js / components / projectValidation / ProjectInformationCheck / index.js View on Github external
function getResourceInfoHint() {
      const infoText = translate('project_validation.resource_id.info');

      if (typeof infoText !== 'string') { // if translate wrapped as react element
        let html = ReactDOMServer.renderToStaticMarkup(infoText);

        if (html) {
          // remove span wrapper if present
          let parts = html.split('<span>');
          html = parts[0] || parts[1];
          parts = html.split('</span>');
          html = parts[0];
          return html;
        }
      }
      return infoText;
    }