Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Replace deprecated findDOMNode call #9052

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions examples/react/__tests__/CheckboxWithLabel-test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// Copyright 2004-present Facebook. All Rights Reserved.

import React from 'react';
import ReactDOM from 'react-dom';
import React, {useRef} from 'react';
import * as TestUtils from 'react-dom/test-utils';
import CheckboxWithLabel from '../CheckboxWithLabel';

it('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkboxNodeRef = useRef(null);

const checkbox = TestUtils.renderIntoDocument(
<CheckboxWithLabel labelOn="On" labelOff="Off" />
<CheckboxWithLabel ref={checkboxNodeRef} labelOn="On" labelOff="Off" />
);

const checkboxNode = ReactDOM.findDOMNode(checkbox);

// Verify that it's Off by default
expect(checkboxNode.textContent).toEqual('Off');
expect(checkboxNodeRef.current.textContent).toEqual('Off');

// Simulate a click and verify that it is now On
TestUtils.Simulate.change(
TestUtils.findRenderedDOMComponentWithTag(checkbox, 'input')
);
expect(checkboxNode.textContent).toEqual('On');
expect(checkboxNodeRef.current.textContent).toEqual('On');
});