@@ -759,4 +759,85 @@ describe('ReactDOMTextarea', () => {
759759 ReactDOM . render ( < textarea defaultValue = { null } /> , container ) ;
760760 expect ( node . defaultValue ) . toBe ( '' ) ;
761761 } ) ;
762+
763+ it ( 'should not warn about missing onChange if value is not set' , ( ) => {
764+ expect ( ( ) => {
765+ ReactTestUtils . renderIntoDocument ( < textarea /> ) ;
766+ } ) . not . toThrow ( ) ;
767+ } ) ;
768+
769+ it ( 'should not warn about missing onChange if value is undefined' , ( ) => {
770+ expect ( ( ) => {
771+ ReactTestUtils . renderIntoDocument ( < textarea value = { undefined } /> ) ;
772+ } ) . not . toThrow ( ) ;
773+ } ) ;
774+
775+ it ( 'should not warn about missing onChange if onChange is set' , ( ) => {
776+ expect ( ( ) => {
777+ const change = jest . fn ( ) ;
778+ ReactTestUtils . renderIntoDocument (
779+ < textarea value = "something" onChange = { change } /> ,
780+ ) ;
781+ } ) . not . toThrow ( ) ;
782+ } ) ;
783+
784+ it ( 'should not warn about missing onChange if disabled is true' , ( ) => {
785+ expect ( ( ) => {
786+ ReactTestUtils . renderIntoDocument (
787+ < textarea value = "something" disabled = { true } /> ,
788+ ) ;
789+ } ) . not . toThrow ( ) ;
790+ } ) ;
791+
792+ it ( 'should not warn about missing onChange if value is not set' , ( ) => {
793+ expect ( ( ) => {
794+ ReactTestUtils . renderIntoDocument (
795+ < textarea value = "something" readOnly = { true } /> ,
796+ ) ;
797+ } ) . not . toThrow ( ) ;
798+ } ) ;
799+
800+ it ( 'should warn about missing onChange if value is false' , ( ) => {
801+ expect ( ( ) =>
802+ ReactTestUtils . renderIntoDocument ( < textarea value = { false } /> ) ,
803+ ) . toErrorDev (
804+ 'Warning: You provided a `value` prop to a form ' +
805+ 'field without an `onChange` handler. This will render a read-only ' +
806+ 'field. If the field should be mutable use `defaultValue`. ' +
807+ 'Otherwise, set either `onChange` or `readOnly`.' ,
808+ ) ;
809+ } ) ;
810+
811+ it ( 'should warn about missing onChange if value is 0' , ( ) => {
812+ expect ( ( ) =>
813+ ReactTestUtils . renderIntoDocument ( < textarea value = { 0 } /> ) ,
814+ ) . toErrorDev (
815+ 'Warning: You provided a `value` prop to a form ' +
816+ 'field without an `onChange` handler. This will render a read-only ' +
817+ 'field. If the field should be mutable use `defaultValue`. ' +
818+ 'Otherwise, set either `onChange` or `readOnly`.' ,
819+ ) ;
820+ } ) ;
821+
822+ it ( 'should warn about missing onChange if value is "0"' , ( ) => {
823+ expect ( ( ) =>
824+ ReactTestUtils . renderIntoDocument ( < textarea value = "0" /> ) ,
825+ ) . toErrorDev (
826+ 'Warning: You provided a `value` prop to a form ' +
827+ 'field without an `onChange` handler. This will render a read-only ' +
828+ 'field. If the field should be mutable use `defaultValue`. ' +
829+ 'Otherwise, set either `onChange` or `readOnly`.' ,
830+ ) ;
831+ } ) ;
832+
833+ it ( 'should warn about missing onChange if value is ""' , ( ) => {
834+ expect ( ( ) =>
835+ ReactTestUtils . renderIntoDocument ( < textarea value = "" /> ) ,
836+ ) . toErrorDev (
837+ 'Warning: You provided a `value` prop to a form ' +
838+ 'field without an `onChange` handler. This will render a read-only ' +
839+ 'field. If the field should be mutable use `defaultValue`. ' +
840+ 'Otherwise, set either `onChange` or `readOnly`.' ,
841+ ) ;
842+ } ) ;
762843} ) ;
0 commit comments