This repository was archived by the owner on Aug 23, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1346,6 +1346,39 @@ describe('<Field /> component', () => {
1346
1346
assert . isFalse ( onChangeFnSpy . called ) ;
1347
1347
} ) ;
1348
1348
1349
+ it ( 'should only execute custom onChange function pertaining to the changed input' , ( ) => {
1350
+ const onChangeFnFoo = ( val ) => val ;
1351
+ const onChangeFnBar = ( val ) => val ;
1352
+ const onChangeFnFooSpy = sinon . spy ( onChangeFnFoo ) ;
1353
+ const onChangeFnBarSpy = sinon . spy ( onChangeFnBar ) ;
1354
+
1355
+ const field = TestUtils . renderIntoDocument (
1356
+ < Provider store = { store } >
1357
+ < div >
1358
+ < Field
1359
+ model = "test.foo"
1360
+ >
1361
+ < input type = "text" onChange = { onChangeFnFooSpy } />
1362
+ </ Field >
1363
+ < Field
1364
+ model = "test.bar"
1365
+ >
1366
+ < input type = "text" onChange = { onChangeFnBarSpy } />
1367
+ </ Field >
1368
+ </ div >
1369
+ </ Provider >
1370
+ ) ;
1371
+
1372
+ const [ _ , controlBar ] = TestUtils . scryRenderedDOMComponentsWithTag ( field , 'input' ) ;
1373
+
1374
+ controlBar . value = 'testing' ;
1375
+
1376
+ TestUtils . Simulate . change ( controlBar ) ;
1377
+
1378
+ assert . isFalse ( onChangeFnFooSpy . called ) ;
1379
+ assert . isTrue ( onChangeFnBarSpy . called ) ;
1380
+ } ) ;
1381
+
1349
1382
it ( 'should persist and return the event even when not returned' , ( ) => {
1350
1383
const onChangeFn = ( ) => { } ;
1351
1384
const onChangeFnSpy = sinon . spy ( onChangeFn ) ;
You can’t perform that action at this time.
0 commit comments