9
9
10
10
'use strict' ;
11
11
12
- import { act } from 'internal-test-utils' ;
13
- import * as React from 'react' ;
14
- import * as ReactDOMClient from 'react-dom/client' ;
15
- import * as ReactDOMServer from 'react-dom/server' ;
16
- import * as ReactTestUtils from 'react-dom/test-utils' ;
12
+ let React ;
13
+ let ReactDOMClient ;
14
+ let ReactDOMServer ;
15
+ let ReactTestUtils ;
16
+ let act ;
17
17
18
18
function getTestDocument ( markup ) {
19
19
const doc = document . implementation . createHTMLDocument ( '' ) ;
@@ -27,8 +27,105 @@ function getTestDocument(markup) {
27
27
}
28
28
29
29
describe ( 'ReactTestUtils' , ( ) => {
30
+ beforeEach ( ( ) => {
31
+ React = require ( 'react' ) ;
32
+ ReactDOMClient = require ( 'react-dom/client' ) ;
33
+ ReactDOMServer = require ( 'react-dom/server' ) ;
34
+ ReactTestUtils = require ( 'react-dom/test-utils' ) ;
35
+ act = require ( 'internal-test-utils' ) . act ;
36
+ } ) ;
37
+
38
+ // @gate !disableDOMTestUtils
30
39
it ( 'Simulate should have locally attached media events' , ( ) => {
31
- expect ( Object . keys ( ReactTestUtils . Simulate ) . sort ( ) ) . toMatchSnapshot ( ) ;
40
+ expect ( Object . keys ( ReactTestUtils . Simulate ) . sort ( ) ) . toMatchInlineSnapshot ( `
41
+ [
42
+ "abort",
43
+ "animationEnd",
44
+ "animationIteration",
45
+ "animationStart",
46
+ "auxClick",
47
+ "beforeInput",
48
+ "blur",
49
+ "canPlay",
50
+ "canPlayThrough",
51
+ "cancel",
52
+ "change",
53
+ "click",
54
+ "close",
55
+ "compositionEnd",
56
+ "compositionStart",
57
+ "compositionUpdate",
58
+ "contextMenu",
59
+ "copy",
60
+ "cut",
61
+ "doubleClick",
62
+ "drag",
63
+ "dragEnd",
64
+ "dragEnter",
65
+ "dragExit",
66
+ "dragLeave",
67
+ "dragOver",
68
+ "dragStart",
69
+ "drop",
70
+ "durationChange",
71
+ "emptied",
72
+ "encrypted",
73
+ "ended",
74
+ "error",
75
+ "focus",
76
+ "gotPointerCapture",
77
+ "input",
78
+ "invalid",
79
+ "keyDown",
80
+ "keyPress",
81
+ "keyUp",
82
+ "load",
83
+ "loadStart",
84
+ "loadedData",
85
+ "loadedMetadata",
86
+ "lostPointerCapture",
87
+ "mouseDown",
88
+ "mouseEnter",
89
+ "mouseLeave",
90
+ "mouseMove",
91
+ "mouseOut",
92
+ "mouseOver",
93
+ "mouseUp",
94
+ "paste",
95
+ "pause",
96
+ "play",
97
+ "playing",
98
+ "pointerCancel",
99
+ "pointerDown",
100
+ "pointerEnter",
101
+ "pointerLeave",
102
+ "pointerMove",
103
+ "pointerOut",
104
+ "pointerOver",
105
+ "pointerUp",
106
+ "progress",
107
+ "rateChange",
108
+ "reset",
109
+ "resize",
110
+ "scroll",
111
+ "seeked",
112
+ "seeking",
113
+ "select",
114
+ "stalled",
115
+ "submit",
116
+ "suspend",
117
+ "timeUpdate",
118
+ "toggle",
119
+ "touchCancel",
120
+ "touchEnd",
121
+ "touchMove",
122
+ "touchStart",
123
+ "transitionEnd",
124
+ "volumeChange",
125
+ "waiting",
126
+ "wheel",
127
+ ]
128
+ ` ) ;
32
129
} ) ;
33
130
34
131
// @gate !disableDOMTestUtils
@@ -575,14 +672,6 @@ describe('ReactTestUtils', () => {
575
672
} ) ;
576
673
expect ( idCallOrder ) . toEqual ( [ CHILD ] ) ;
577
674
} ) ;
578
-
579
- // @gate disableDOMTestUtils
580
- it ( 'throws' , async ( ) => {
581
- expect ( ReactTestUtils . Simulate . click ) . toThrow (
582
- '`Simulate` was removed from `react-dom/test-utils`. ' +
583
- 'See https://react.dev/warnings/react-dom-test-utils for more info.' ,
584
- ) ;
585
- } ) ;
586
675
} ) ;
587
676
588
677
// @gate !disableDOMTestUtils
@@ -626,14 +715,6 @@ describe('ReactTestUtils', () => {
626
715
expect ( renderedComponentType ) . toBe ( instance ) ;
627
716
} ) ;
628
717
629
- // @gate disableDOMTestUtils
630
- it ( 'throws on every removed function' , async ( ) => {
631
- expect ( ReactTestUtils . isDOMComponent ) . toThrow (
632
- '`isDOMComponent` was removed from `react-dom/test-utils`. ' +
633
- 'See https://react.dev/warnings/react-dom-test-utils for more info.' ,
634
- ) ;
635
- } ) ;
636
-
637
718
// @gate __DEV__
638
719
it ( 'warns when using `act`' , ( ) => {
639
720
expect ( ( ) => {
0 commit comments