@@ -1310,6 +1310,42 @@ describe('ReactDOMComponent', () => {
1310
1310
expect ( console . log . calls . argsFor ( 1 ) [ 0 ] ) . toContain ( 'onLoad called' ) ;
1311
1311
}
1312
1312
} ) ;
1313
+
1314
+ it ( 'should receive a load event on <link> elements' , ( ) => {
1315
+ const container = document . createElement ( 'div' ) ;
1316
+ const onLoad = jest . fn ( ) ;
1317
+
1318
+ ReactDOM . render (
1319
+ < link href = "http://example.org/link" onLoad = { onLoad } /> ,
1320
+ container ,
1321
+ ) ;
1322
+
1323
+ const loadEvent = document . createEvent ( 'Event' ) ;
1324
+ const link = container . getElementsByTagName ( 'link' ) [ 0 ] ;
1325
+
1326
+ loadEvent . initEvent ( 'load' , false , false ) ;
1327
+ link . dispatchEvent ( loadEvent ) ;
1328
+
1329
+ expect ( onLoad ) . toHaveBeenCalledTimes ( 1 ) ;
1330
+ } ) ;
1331
+
1332
+ it ( 'should receive an error event on <link> elements' , ( ) => {
1333
+ const container = document . createElement ( 'div' ) ;
1334
+ const onError = jest . fn ( ) ;
1335
+
1336
+ ReactDOM . render (
1337
+ < link href = "http://example.org/link" onError = { onError } /> ,
1338
+ container ,
1339
+ ) ;
1340
+
1341
+ const errorEvent = document . createEvent ( 'Event' ) ;
1342
+ const link = container . getElementsByTagName ( 'link' ) [ 0 ] ;
1343
+
1344
+ errorEvent . initEvent ( 'error' , false , false ) ;
1345
+ link . dispatchEvent ( errorEvent ) ;
1346
+
1347
+ expect ( onError ) . toHaveBeenCalledTimes ( 1 ) ;
1348
+ } ) ;
1313
1349
} ) ;
1314
1350
1315
1351
describe ( 'updateComponent' , ( ) => {
0 commit comments