@@ -1588,27 +1588,43 @@ describe('ReactDOMInput', () => {
1588
1588
1589
1589
describe ( 'When given a Symbol value' , function ( ) {
1590
1590
it ( 'does not allow initial assignment of Symbols to value' , function ( ) {
1591
+ spyOnDev ( console , 'error' ) ;
1591
1592
var container = document . createElement ( 'div' ) ;
1592
- ReactDOM . render ( < input value = { Symbol ( 'foobar' ) } /> , container ) ;
1593
+ ReactDOM . render ( < input value = { Symbol ( 'foobar' ) } readOnly /> , container ) ;
1593
1594
var node = container . firstChild ;
1594
1595
1595
1596
expect ( node . value ) . toBe ( '' ) ;
1596
1597
expect ( node . getAttribute ( 'value' ) ) . toBe ( '' ) ;
1598
+
1599
+ if ( __DEV__ ) {
1600
+ expect ( console . error . calls . count ( ) ) . toBe ( 1 ) ;
1601
+ expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
1602
+ 'Invalid value for prop `value`' ,
1603
+ ) ;
1604
+ }
1597
1605
} ) ;
1598
1606
1599
1607
it ( 'does not update the value to a Symbol' , function ( ) {
1608
+ spyOnDev ( console , 'error' ) ;
1600
1609
var container = document . createElement ( 'div' ) ;
1601
- ReactDOM . render ( < input value = { '' } /> , container ) ;
1602
- ReactDOM . render ( < input value = { Symbol ( 'foobar' ) } /> , container ) ;
1610
+ ReactDOM . render ( < input value = { '' } readOnly /> , container ) ;
1611
+ ReactDOM . render ( < input value = { Symbol ( 'foobar' ) } readOnly /> , container ) ;
1603
1612
var node = container . firstChild ;
1604
1613
1605
1614
expect ( node . value ) . toBe ( '' ) ;
1606
1615
expect ( node . getAttribute ( 'value' ) ) . toBe ( '' ) ;
1616
+
1617
+ if ( __DEV__ ) {
1618
+ expect ( console . error . calls . count ( ) ) . toBe ( 1 ) ;
1619
+ expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
1620
+ 'Invalid value for prop `value`' ,
1621
+ ) ;
1622
+ }
1607
1623
} ) ;
1608
1624
1609
1625
it ( 'does not allow initial assignment of Symbols to defaultValue' , function ( ) {
1610
1626
var container = document . createElement ( 'div' ) ;
1611
- ReactDOM . render ( < input value = { Symbol ( 'foobar' ) } /> , container ) ;
1627
+ ReactDOM . render ( < input defaultValue = { Symbol ( 'foobar' ) } /> , container ) ;
1612
1628
var node = container . firstChild ;
1613
1629
1614
1630
expect ( node . value ) . toBe ( '' ) ;
@@ -1628,27 +1644,43 @@ describe('ReactDOMInput', () => {
1628
1644
1629
1645
describe ( 'When given a function value' , function ( ) {
1630
1646
it ( 'does not allow initial assignment of functions to value' , function ( ) {
1647
+ spyOnDev ( console , 'error' ) ;
1631
1648
var container = document . createElement ( 'div' ) ;
1632
- ReactDOM . render ( < input value = { ( ) => { } } /> , container ) ;
1649
+ ReactDOM . render ( < input value = { ( ) => { } } readOnly /> , container ) ;
1633
1650
var node = container . firstChild ;
1634
1651
1635
1652
expect ( node . value ) . toBe ( '' ) ;
1636
1653
expect ( node . getAttribute ( 'value' ) ) . toBe ( '' ) ;
1654
+
1655
+ if ( __DEV__ ) {
1656
+ expect ( console . error . calls . count ( ) ) . toBe ( 1 ) ;
1657
+ expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
1658
+ 'Invalid value for prop `value`' ,
1659
+ ) ;
1660
+ }
1637
1661
} ) ;
1638
1662
1639
1663
it ( 'does not update the value to a function' , function ( ) {
1664
+ spyOnDev ( console , 'error' ) ;
1640
1665
var container = document . createElement ( 'div' ) ;
1641
1666
ReactDOM . render ( < input value = { '' } /> , container ) ;
1642
1667
ReactDOM . render ( < input value = { ( ) => { } } /> , container ) ;
1643
1668
var node = container . firstChild ;
1644
1669
1645
1670
expect ( node . value ) . toBe ( '' ) ;
1646
1671
expect ( node . getAttribute ( 'value' ) ) . toBe ( '' ) ;
1672
+
1673
+ if ( __DEV__ ) {
1674
+ expect ( console . error . calls . count ( ) ) . toBe ( 1 ) ;
1675
+ expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
1676
+ 'Invalid value for prop `value`' ,
1677
+ ) ;
1678
+ }
1647
1679
} ) ;
1648
1680
1649
1681
it ( 'does not allow initial assignment of functions to defaultValue' , function ( ) {
1650
1682
var container = document . createElement ( 'div' ) ;
1651
- ReactDOM . render ( < input value = { ( ) => { } } /> , container ) ;
1683
+ ReactDOM . render ( < input defaultValue = { ( ) => { } } readOnly /> , container ) ;
1652
1684
var node = container . firstChild ;
1653
1685
1654
1686
expect ( node . value ) . toBe ( '' ) ;
0 commit comments