diff --git a/packages/react-dom/src/__tests__/ReactDOMOption-test.js b/packages/react-dom/src/__tests__/ReactDOMOption-test.js index bd30ae23a1dd5..09df9137ce927 100644 --- a/packages/react-dom/src/__tests__/ReactDOMOption-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMOption-test.js @@ -15,6 +15,7 @@ describe('ReactDOMOption', () => { let ReactTestUtils; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactTestUtils = require('react-dom/test-utils'); @@ -41,9 +42,10 @@ describe('ReactDOMOption', () => { expect(() => { node = ReactTestUtils.renderIntoDocument(el); }).toWarnDev( - '
cannot appear as a child of ); + }).toThrow('Objects are not valid as a React child'); + expect(() => { + ReactTestUtils.renderIntoDocument(); + }).toThrow('Objects are not valid as a React child'); + expect(() => { + ReactTestUtils.renderIntoDocument( + , + ); + }).toThrow('Objects are not valid as a React child'); + expect(() => { + ReactTestUtils.renderIntoDocument( + , + ); + }).toThrow('Objects are not valid as a React child'); + }); + + it('should support element-ish child', () => { + // This is similar to . + // It's important that we toString it. + let obj = { + $$typeof: Symbol.for('react.element'), + type: props => props.content, + ref: null, + key: null, + props: { + content: 'hello', + }, + toString() { + return this.props.content; + }, + }; + + let node = ReactTestUtils.renderIntoDocument(); + expect(node.innerHTML).toBe('hello'); + + node = ReactTestUtils.renderIntoDocument(); + expect(node.innerHTML).toBe('hello'); + + expect(() => { + node = ReactTestUtils.renderIntoDocument( + , + ); + }).toWarnDev( + 'Only strings and numbers are supported as , + ); + expect(node.innerHTML).toBe('1hello2'); + }); + it('should be able to use dangerouslySetInnerHTML on option', () => { let stub =