1
1
// Copyright (c) 2016, the Clean project authors. Please see the AUTHORS file
2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
-
4
+ // ignore_for_file: deprecated_member_use_from_same_package
5
+ @Deprecated ('Use the react_testing_library package instead.' )
5
6
@JS ()
6
7
library react.test_utils;
7
8
8
- import 'dart:js_util' show getProperty;
9
-
10
9
import 'package:js/js.dart' ;
11
10
import 'package:react/react_client.dart' ;
12
11
import 'package:react/react_client/js_interop_helpers.dart' ;
13
12
import 'package:react/react_client/react_interop.dart' ;
14
13
import 'package:react/src/react_test_utils/simulate_wrappers.dart' as sw;
14
+ import 'package:react/src/react_test_utils/internal_test_utils.dart' as itu;
15
15
16
16
// Notes
17
17
// ---------------------------------------------------------------------------
@@ -36,8 +36,10 @@ import 'package:react/src/react_test_utils/simulate_wrappers.dart' as sw;
36
36
///
37
37
/// * For DOM components, this with return the String corresponding to its tagName ('div', 'a', etc.).
38
38
/// * For custom composite components React.createClass()-based components, this will return the [ReactClass] .
39
- dynamic getComponentTypeV2 (ReactComponentFactoryProxy componentFactory) => componentFactory.type;
39
+ @Deprecated ('Use the react_testing_library package instead.' )
40
+ final getComponentTypeV2 = itu.getComponentTypeV2;
40
41
42
+ @Deprecated ('Use the react_testing_library package instead.' )
41
43
typedef bool ComponentTestFunction (/* [1] */ component);
42
44
43
45
dynamic _jsifyEventData (Map eventData) => jsifyAndAllowInterop (eventData ?? const {});
@@ -51,6 +53,7 @@ dynamic _jsifyEventData(Map eventData) => jsifyAndAllowInterop(eventData ?? cons
51
53
///
52
54
/// This should include all events documented at:
53
55
/// http://facebook.github.io/react/docs/events.html
56
+ @Deprecated ('Use the UserEvent or fireEvent utilities from the react_testing_library package instead.' )
54
57
class Simulate {
55
58
static void animationEnd (/* [1] */ node, [Map eventData]) =>
56
59
sw.Simulate .animationEnd (node, _jsifyEventData (eventData));
@@ -120,6 +123,7 @@ class Simulate {
120
123
///
121
124
/// Included in Dart for completeness
122
125
@JS ('React.addons.TestUtils.findAllInRenderedTree' )
126
+ @Deprecated ('Use the react_testing_library package instead.' )
123
127
external List <dynamic > findAllInRenderedTree (
124
128
/* [1] */ tree,
125
129
ComponentTestFunction test);
@@ -128,6 +132,7 @@ external List<dynamic> findAllInRenderedTree(
128
132
/// result, and returns that one result, or throws exception if there is
129
133
/// any other number of matches besides one.
130
134
@JS ('React.addons.TestUtils.findRenderedDOMComponentWithClass' )
135
+ @Deprecated ('Use the react_testing_library package instead.' )
131
136
external dynamic /* [1] */ findRenderedDOMComponentWithClass (
132
137
/* [1] */ tree,
133
138
String className);
@@ -136,63 +141,51 @@ external dynamic /* [1] */ findRenderedDOMComponentWithClass(
136
141
/// and returns that one result, or throws exception if there is any other
137
142
/// number of matches besides one.
138
143
@JS ('React.addons.TestUtils.findRenderedDOMComponentWithTag' )
144
+ @Deprecated ('Use the react_testing_library package instead.' )
139
145
external dynamic /* [1] */ findRenderedDOMComponentWithTag (
140
146
/* [1] */ tree,
141
147
String tag);
142
148
143
149
@JS ('React.addons.TestUtils.findRenderedComponentWithType' )
150
+ @Deprecated ('Use the react_testing_library package instead.' )
144
151
external dynamic /* [1] */ _findRenderedComponentWithType (
145
152
/* [1] */ tree,
146
153
dynamic type);
147
154
148
155
/// Same as [scryRenderedComponentsWithTypeV2] but expects there to be one result
149
156
/// and returns that one result, or throws exception if there is any other
150
157
/// number of matches besides one.
158
+ @Deprecated ('Use the react_testing_library package instead.' )
151
159
/* [1] */ findRenderedComponentWithTypeV2 (
152
160
/* [1] */ tree,
153
161
ReactComponentFactoryProxy componentFactory) {
154
162
return _findRenderedComponentWithType (tree, getComponentTypeV2 (componentFactory));
155
163
}
156
164
157
- @JS ('React.addons.TestUtils.isCompositeComponent' )
158
- external bool _isCompositeComponent (/* [1] */ instance);
159
-
160
165
/// Returns true if element is a composite component.
161
166
/// (created with React.createClass()).
162
- bool isCompositeComponent (/* [1] */ instance) {
163
- return _isCompositeComponent (instance)
164
- // Workaround for DOM components being detected as composite: https://github.com/facebook/react/pull/3839
165
- &&
166
- getProperty (instance, 'tagName' ) == null ;
167
- }
168
-
169
- @JS ('React.addons.TestUtils.isCompositeComponentWithType' )
170
- external bool _isCompositeComponentWithType (/* [1] */ instance, dynamic type);
167
+ @Deprecated ('Use the react_testing_library package instead.' )
168
+ final isCompositeComponent = itu.isCompositeComponent;
171
169
172
170
/// Returns `true` if instance is a custom composite component created using `React.createClass()`
173
171
/// that is of the [ReactComponentFactoryProxy.type] of the provided [componentFactory] .
174
- bool isCompositeComponentWithTypeV2 (
175
- /* [1] */ instance,
176
- ReactComponentFactoryProxy componentFactory) {
177
- return _isCompositeComponentWithType (instance, getComponentTypeV2 (componentFactory));
178
- }
172
+ @Deprecated ('Use the react_testing_library package instead.' )
173
+ final isCompositeComponentWithTypeV2 = itu.isCompositeComponentWithTypeV2;
179
174
180
175
/// Returns true if instance is a DOM component (such as a <div> or <span>).
181
176
@JS ('React.addons.TestUtils.isDOMComponent' )
182
- external bool isDOMComponent (/* [1] */ instance);
177
+ @Deprecated ('Use the react_testing_library package instead.' )
178
+ final isDOMComponent = itu.isDOMComponent;
183
179
184
180
/// Returns true if [object] is a valid React component.
185
181
@JS ('React.addons.TestUtils.isElement' )
182
+ @Deprecated ('Use the react_testing_library package instead.' )
186
183
external bool isElement (dynamic object);
187
184
188
- @JS ('React.addons.TestUtils.isElementOfType' )
189
- external bool _isElementOfType (dynamic element, dynamic componentClass);
190
-
191
185
/// Returns `true` if [element] is a [ReactElement]
192
186
/// that is of the [ReactComponentFactoryProxy.type] of the provided [componentFactory] .
193
- bool isElementOfTypeV2 (dynamic element, ReactComponentFactoryProxy componentFactory) {
194
- return _isElementOfType (element, getComponentTypeV2 (componentFactory));
195
- }
187
+ @Deprecated ('Use the react_testing_library package instead.' )
188
+ final isElementOfTypeV2 = itu.isElementOfTypeV2;
196
189
197
190
@JS ('React.addons.TestUtils.scryRenderedComponentsWithType' )
198
191
external List <dynamic > /* [1] */ _scryRenderedComponentsWithType (
@@ -201,6 +194,7 @@ external List<dynamic> /* [1] */ _scryRenderedComponentsWithType(
201
194
202
195
/// Finds all instances within the provided [tree]
203
196
/// that are of the [ReactComponentFactoryProxy.type] of the provided [componentFactory] .
197
+ @Deprecated ('Use the react_testing_library package instead.' )
204
198
List <dynamic > /* [1] */ scryRenderedComponentsWithTypeV2 (
205
199
/* [1] */ tree,
206
200
ReactComponentFactoryProxy componentFactory) {
@@ -211,6 +205,7 @@ List<dynamic> /* [1] */ scryRenderedComponentsWithTypeV2(
211
205
212
206
/// Finds all instances of components in the rendered tree that are DOM
213
207
/// components with the class name matching className.
208
+ @Deprecated ('Use the react_testing_library package instead.' )
214
209
external List <dynamic > scryRenderedDOMComponentsWithClass (
215
210
/* [1] */ tree,
216
211
String className);
@@ -219,19 +214,22 @@ external List<dynamic> scryRenderedDOMComponentsWithClass(
219
214
220
215
/// Finds all instances of components in the rendered tree that are DOM
221
216
/// components with the tag name matching tagName.
217
+ @Deprecated ('Use the react_testing_library package instead.' )
222
218
external List <dynamic > scryRenderedDOMComponentsWithTag (
223
219
/* [1] */ tree,
224
220
String tagName);
225
221
226
222
/// Render a Component into a detached DOM node in the document.
227
223
@JS ('React.addons.TestUtils.renderIntoDocument' )
224
+ @Deprecated ('Use the render() utility from the react_testing_library package instead.' )
228
225
external /* [1] */ renderIntoDocument (ReactElement instance);
229
226
230
227
/// Pass a mocked component module to this method to augment it with useful
231
228
/// methods that allow it to be used as a dummy React component. Instead of
232
229
/// rendering as usual, the component will become a simple <div> (or other tag
233
230
/// if mockTagName is provided) containing any provided children.
234
231
@JS ('React.addons.TestUtils.mockComponent' )
232
+ @Deprecated ('Use the react_testing_library package instead.' )
235
233
external ReactClass mockComponent (ReactClass componentClass, String mockTagName);
236
234
237
235
/// Returns a ReactShallowRenderer instance
@@ -255,6 +253,7 @@ external ReactShallowRenderer createRenderer();
255
253
/// See react_with_addons.js#ReactShallowRenderer
256
254
@JS ()
257
255
@anonymous
256
+ @Deprecated ('Use the react_testing_library package instead.' )
258
257
class ReactShallowRenderer {
259
258
/// Get the rendered output. [render] must be called first
260
259
external ReactElement getRenderOutput ();
0 commit comments