From 9fd760ce75fd76716888997852ca85394eeab49a Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Mon, 20 Jan 2020 15:12:30 +0000 Subject: [PATCH] Add disable ; - let node; + if (ReactFeatureFlags.disableTextareaChildren) { + it('should ignore children content', () => { + const container = document.createElement('div'); + let stub = ; + let node; - expect(() => { - node = renderTextarea(stub, container); - }).toErrorDev( - 'Use the `defaultValue` or `value` props instead of setting children on , container); + expect(node.value).toEqual(''); + }); + } - expect(node.value).toBe('giraffe'); + if (ReactFeatureFlags.disableTextareaChildren) { + it('should receive defaultValue and still ignore children content', () => { + let node; - // Changing children should do nothing, it functions like `defaultValue`. - stub = ReactDOM.render(, container); - expect(node.value).toEqual('giraffe'); - }); + expect(() => { + node = renderTextarea( + , + ); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on ; + let node; + + expect(() => { + node = renderTextarea(stub, container); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on , container); + expect(node.value).toEqual('giraffe'); + }); + } it('should keep value when switching to uncontrolled element if not changed', () => { const container = document.createElement('div'); @@ -342,71 +379,120 @@ describe('ReactDOMTextarea', () => { expect(node.value).toEqual('puppies'); }); - it('should allow numbers as children', () => { - let node; - expect(() => { - node = renderTextarea(); - }).toErrorDev( - 'Use the `defaultValue` or `value` props instead of setting children on ); - }).toErrorDev( - 'Use the `defaultValue` or `value` props instead of setting children on ); - }).toErrorDev( - 'Use the `defaultValue` or `value` props instead of setting children on , - ), - ).toThrow('); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on ); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on ); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on ); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on ); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on ); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on , - )), - ).not.toThrow(); - }).toErrorDev( - 'Use the `defaultValue` or `value` props instead of setting children on , + )), + ).not.toThrow(); + }).toErrorDev( + 'Use the `defaultValue` or `value` props instead of setting children on