-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix / reorganize tests, deprecate RTU
- Loading branch information
1 parent
02068ca
commit e259e9d
Showing
72 changed files
with
625 additions
and
705 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*.dart] | ||
max_line_length = 120 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@JS() | ||
library react.src.react_test_utils.internal_test_utils; | ||
|
||
import 'dart:js_util' show getProperty; | ||
|
||
import 'package:js/js.dart'; | ||
import 'package:react/react_client.dart'; | ||
import 'package:react/react_client/react_interop.dart'; | ||
|
||
/// Returns the [ReactComponentFactoryProxy.type] of a given [componentFactory]. | ||
/// | ||
/// * For DOM components, this with return the String corresponding to its tagName ('div', 'a', etc.). | ||
/// * For custom composite components React.createClass()-based components, this will return the [ReactClass]. | ||
dynamic getComponentTypeV2(ReactComponentFactoryProxy componentFactory) => componentFactory.type; | ||
|
||
@JS('React.addons.TestUtils.isCompositeComponent') | ||
external bool _isCompositeComponent(/* [1] */ instance); | ||
|
||
/// Returns true if element is a composite component. | ||
/// (created with React.createClass()). | ||
bool isCompositeComponent(/* [1] */ instance) { | ||
return _isCompositeComponent(instance) | ||
// Workaround for DOM components being detected as composite: https://github.com/facebook/react/pull/3839 | ||
&& | ||
getProperty(instance, 'tagName') == null; | ||
} | ||
|
||
@JS('React.addons.TestUtils.isCompositeComponentWithType') | ||
external bool _isCompositeComponentWithType(/* [1] */ instance, dynamic type); | ||
|
||
/// Returns `true` if instance is a custom composite component created using `React.createClass()` | ||
/// that is of the [ReactComponentFactoryProxy.type] of the provided [componentFactory]. | ||
bool isCompositeComponentWithTypeV2( | ||
/* [1] */ instance, | ||
ReactComponentFactoryProxy componentFactory) { | ||
return _isCompositeComponentWithType(instance, getComponentTypeV2(componentFactory)); | ||
} | ||
|
||
/// Returns true if instance is a DOM component (such as a <div> or <span>). | ||
@JS('React.addons.TestUtils.isDOMComponent') | ||
external bool isDOMComponent(/* [1] */ instance); | ||
|
||
/// Returns true if [object] is a valid React component. | ||
@JS('React.addons.TestUtils.isElement') | ||
external bool isElement(dynamic object); | ||
|
||
@JS('React.addons.TestUtils.isElementOfType') | ||
external bool _isElementOfType(dynamic element, dynamic componentClass); | ||
|
||
/// Returns `true` if [element] is a [ReactElement] | ||
/// that is of the [ReactComponentFactoryProxy.type] of the provided [componentFactory]. | ||
bool isElementOfTypeV2(dynamic element, ReactComponentFactoryProxy componentFactory) { | ||
return _isElementOfType(element, getComponentTypeV2(componentFactory)); | ||
} | ||
|
||
/// Render a Component into a detached DOM node in the document. | ||
@JS('React.addons.TestUtils.renderIntoDocument') | ||
external ReactComponent renderIntoDocument(ReactElement instance); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<!-- The "testName" placeholder will be replaced with a unique name for | ||
each test. --> | ||
<title>{{testName}} Test</title> | ||
|
||
<!-- Load custom assets needed by the test. --> | ||
<script src="packages/react/react_with_addons.js"></script> | ||
<script src="packages/react/react_dom.js"></script> | ||
<script src="packages/react_testing_library/js/react-testing-library.js"></script> | ||
|
||
<!-- Every template must include this placeholder. --> | ||
{{testScript}} | ||
<!-- It will be replaced by the builder with the required <link> tag: | ||
<link rel="x-dart-test" href="..."> | ||
--> | ||
|
||
<!-- Every template must include the test runner script. --> | ||
<script src="packages/test/dart.js"></script> | ||
</head> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<!-- The "testName" placeholder will be replaced with a unique name for | ||
each test. --> | ||
<title>{{testName}} Test</title> | ||
|
||
<!-- Load custom assets needed by the test. --> | ||
<script src="packages/react/react_with_addons.js"></script> | ||
<script src="packages/react/react_dom.js"></script> | ||
<script src="packages/react_testing_library/js/react-testing-library.js"></script> | ||
|
||
<script> | ||
window._JsFoo = class JsFooComponent extends React.Component { | ||
render() { | ||
return React.createElement("div", this.props, this.props.children); | ||
} | ||
}; | ||
|
||
window._JsFooFunction = React.forwardRef((props, ref) => ( | ||
React.createElement("div", {...props, ref: ref}) | ||
)); | ||
</script> | ||
|
||
<!-- Every template must include this placeholder. --> | ||
{{testScript}} | ||
<!-- It will be replaced by the builder with the required <link> tag: | ||
<link rel="x-dart-test" href="..."> | ||
--> | ||
|
||
<!-- Every template must include the test runner script. --> | ||
<script src="packages/test/dart.js"></script> | ||
</head> | ||
</html> |
Oops, something went wrong.