How to use the react-dom/test-utils.findRenderedComponentWithType 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 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 graphistry / falcor / packages / falcor-react-schema / src / components / __tests__ / Provider-tests.js View on Github external
it('Should make the falcorModel available in the context', () => {
        const { App, model } = testInit();
        const tree = TestUtils.renderIntoDocument(
            
                
            
        )
        const child = TestUtils.findRenderedComponentWithType(tree, Child)
        expect(child.context.falcorModel).toBe(model);
    });
});
github department-of-veterans-affairs / vets-website / src / platform / testing / unit / schemaform-utils.jsx View on Github external
export function submitForm(form) {
  ReactTestUtils.findRenderedComponentWithType(form, Form).onSubmit({
    preventDefault: f => f,
  });
}
github bitovi / ylem / test / connect.js View on Github external
);
		});

		const parentInstance = ReactTestUtils.renderIntoDocument();
		const parentViewModel = parentInstance.observable;
		const parentDiv = ReactTestUtils.findRenderedDOMComponentWithTag(parentInstance, 'div');

		const child0ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child0).observable;
		const child00ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child00).observable;
		const child000ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child000).observable;
		const child01ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child01).observable;
		const child1ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child1).observable;
		const child10ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child10).observable;
		const child100ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child100).observable;
		const child1000ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child1000).observable;
		const child11ViewModel = ReactTestUtils.findRenderedComponentWithType(parentInstance, Child11).observable;

		assert.equal(getTextFromElement(parentDiv), '01!23@4#5678', '01!23@4#5678');
		child0ViewModel.value = 'a';
		assert.equal(getTextFromElement(parentDiv), 'a1!23@4#5678', 'a1!23@4#5678');
		child00ViewModel.value = 'b';
		assert.equal(getTextFromElement(parentDiv), 'ab!23@4#5678', 'ab!23@4#5678');
		child000ViewModel.value = 'c';
		assert.equal(getTextFromElement(parentDiv), 'ab!c3@4#5678', 'ab!c3@4#5678');
		child01ViewModel.value = 'd';
		assert.equal(getTextFromElement(parentDiv), 'ab!cd@4#5678', 'ab!cd@4#5678');
		child1ViewModel.value = 'e';
github mlaursen / react-md / src / js / TextFields / __tests__ / TextField.js View on Github external
const props = {
      id: 'test',
      onKeyPress,
      onKeyUp,
      onCopy,
      onCut,
      onPaste,
      onInput,
      onSelect,
      onCompositionStart,
      onCompositionUpdate,
      onCompositionEnd,
    };

    const container = renderIntoDocument();
    const input = findRenderedComponentWithType(container, InputField);

    expect(input.props.onKeyPress).toBe(onKeyPress);
    expect(input.props.onKeyUp).toBe(onKeyUp);
    expect(input.props.onCopy).toBe(onCopy);
    expect(input.props.onCut).toBe(onCut);
    expect(input.props.onPaste).toBe(onPaste);
    expect(input.props.onInput).toBe(onInput);
    expect(input.props.onSelect).toBe(onSelect);
    expect(input.props.onCompositionStart).toBe(onCompositionStart);
    expect(input.props.onCompositionUpdate).toBe(onCompositionUpdate);
    expect(input.props.onCompositionEnd).toBe(onCompositionEnd);
  });
github mlaursen / react-md / src / js / Sliders / __tests__ / Slider.js View on Github external
expect(props.trackFillWidth).toBe(slider.state.trackFillWidth);
    expect(props.on).toBe(false);
    expect(props.off).toBe(true);
    expect(props.maskInked).toBe(slider.state.maskInked);
    expect(props.onThumbKeyUp).toBe(slider._handleKeyUp);
    expect(props.onThumbKeyDown).toBe(slider._handleKeyDown);
    expect(props.onThumbFocus).toBe(slider._handleFocus);
    expect(props.discrete).toBeUndefined();
    expect(props.tickWidth).toBe(Slider.defaultProps.tickWidth);
    expect(props.discreteTicks).toBeUndefined();
    expect(props.step).toBe(Slider.defaultProps.step);
    expect(props.scale).toBe(slider.state.scale);
    expect(props.value).toBe(slider.state.value);

    slider = renderIntoDocument();
    props = findRenderedComponentWithType(slider, Track).props;
    expect(props.disabled).toBe(true);
  });
github adazzle / react-data-grid / test / browser / Viewport / scroll.spec.js View on Github external
beforeEach(function() {
    //ensure we have the sanbox element (karma, etc)
    if(document.getElementById('sandbox') === null) {
      //using native DOM not jQuery/zepto/etc
      var sbox=document.createElement("div");
      sbox.id="sandbox";
      document.body.appendChild(sbox);
    }
      //create a fixed dimension container so we can predict scroll behaviour
    document.getElementById('sandbox').innerHTML += '<div id="gridContainer" style="width:600px;height:500px"></div>';
    //render the grid into the DOM
    this.grid = gridHelpers.renderGrid({containerId: 'gridContainer'});
    this.canvas = ReactTests.findRenderedComponentWithType(this.grid, Canvas);
    this.viewport = ReactTests.findRenderedComponentWithType(this.grid, Viewport);
    this.header = ReactTests.findRenderedComponentWithType(this.grid, Header);
  });
github schiehll / react-globally / src / Provider.spec.js View on Github external
it('should wrap the given children with a Broadcast component', () =&gt; {
    const initialState = { value: 0 }
    const tree = TestUtils.renderIntoDocument(
      
        
      
    )

    const broadcast = TestUtils.findRenderedComponentWithType(tree, Broadcast)
    const child = TestUtils.findRenderedComponentWithType(broadcast, Child)

    expect(child).toBeInstanceOf(Child)
  })
github Sage / carbon / src / components / table / table-row / table-row.spec.js View on Github external
it('calls onSelect', () =&gt; {
        const spy = jasmine.createSpy();
        instance = TestUtils.renderIntoDocument(<table></table>);
        row = TestUtils.findRenderedComponentWithType(instance, TableRow);
        row.onRowClick();
        expect(spy).toHaveBeenCalledWith('foo', true, row);
      });
    });
github Sage / carbon / src / components / table / table.spec.js View on Github external
beforeEach(() => {
      row = TestUtils.findRenderedComponentWithType(instance, TableRow);
      spyOn(row, 'setState');
    });