-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIP-2413: Get tests passing with the DDC #86
Changes from 3 commits
03e9a87
5b80d10
8a42ba9
452adae
0fa13a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,15 @@ dev_dependencies: | |
coverage: "^0.7.2" | ||
dart_dev: "^1.7.6" | ||
mockito: "^0.11.0" | ||
over_react_test: "^1.0.0" | ||
test: "^0.12.6+2" | ||
|
||
dependency_overrides: | ||
react: | ||
git: | ||
url: [email protected]:clairesarsam-wf/react-dart.git | ||
ref: 9e3a349fd6765afb4531192c21a5e7bc74c5d7a0 | ||
|
||
transformers: | ||
- over_react: | ||
$exclude: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,15 +25,20 @@ import 'package:over_react/over_react.dart'; | |
import 'package:react/react_client.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
|
||
main() { | ||
group('Dom component:', () { | ||
ClassMirror domClassMirror = reflectClass(Dom); | ||
|
||
List<MethodMirror> methods = domClassMirror.staticMembers.values.toList(); | ||
List<MethodMirror> methods = []; | ||
ClassMirror domClassMirror; | ||
|
||
setUpAll(() { | ||
expect(methods, isNotEmpty, reason: 'should have properly reflected the static members.'); | ||
domClassMirror = reflectClass(Dom); | ||
|
||
// staticMembers is not implemented for the DDC and will throw is this test is loaded even if it's not run. | ||
try { | ||
methods = domClassMirror.staticMembers.values.toList(); | ||
|
||
expect(methods, isNotEmpty, reason: 'should have properly reflected the static members.'); | ||
} catch(e) {} | ||
}); | ||
|
||
for (var element in methods) { | ||
|
@@ -57,5 +62,5 @@ main() { | |
expect(component.type, equalsIgnoringCase(expectedTagName)); | ||
}); | ||
} | ||
}); | ||
}, tags: 'no-ddc'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this disabled in the DDC? Should have a comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, we should really still test these in the DDC if possible. What about if we enumerated these, and just checked them against the reflected values, like so? const expectedStaticMethods = const <Symbol> [#div, #span, ...];
var actualMethods;
try {
actualMethods = domClassMirror.staticMembers.values.map((m) => m.simpleName).toList();
} catch(e) {}
if (actualMethods != null) {
expect(actualMethods, unorderedEquals(expectedStaticMethods),
reason: '`expectedStaticMethods` needs to be updated');
}
for (var method in expectedStaticMethods) {
String name = MirrorSystem.getName(method);
... |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -437,6 +437,6 @@ void main() { | |
|
||
group('common component functionality:', () { | ||
commonComponentTests(ResizeSensor); | ||
}); | ||
}, tags: 'no-ddc'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this disabled in the DDC? Should have a comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't use |
||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,6 @@ import '../../../test_util/test_util.dart'; | |
|
||
main() { | ||
group('transformed component integration:', () { | ||
test('props class cannot be instantiated directly', () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this test removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prop classes are made abstract by the transformer and the DDC was failing on instantiating an abstract object. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this test was leftover from before that was the case, so it's not really necessary anymore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
expect(() { | ||
new ComponentTestProps(); | ||
}, throwsA(const isInstanceOf<AbstractClassInstantiationError>())); | ||
}); | ||
|
||
test('component class can be instantiated directly', () { | ||
var instance; | ||
expect(() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,7 @@ void mapProxyTests(Map mapProxyFactory(Map proxiedMap)) { | |
expect(proxy.values, equals(['value'])); | ||
verify(mock.values); | ||
}); | ||
}); | ||
}, tags: 'no-ddc'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this disabled in the DDC? Should have a comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mocks don't work in the DDC. I'll add a comment |
||
} | ||
|
||
class MockMap extends Mock implements Map {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ main() { | |
expect(syntheticKeyboardEvent.metaKey, isFalse); | ||
expect(syntheticKeyboardEvent.repeat, isFalse); | ||
expect(syntheticKeyboardEvent.shiftKey, isFalse); | ||
}); | ||
}, tags: 'no-ddc'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this disabled in the DDC? Should have a comment |
||
|
||
test('wrapNativeMouseEvent', () { | ||
var nativeMouseEvent = new MockMouseEvent(); | ||
|
@@ -126,7 +126,7 @@ main() { | |
expect(syntheticMouseEvent.screenX, isNull); | ||
expect(syntheticMouseEvent.screenY, isNull); | ||
expect(syntheticMouseEvent.shiftKey, isFalse); | ||
}); | ||
}, tags: 'no-ddc'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this disabled in the DDC? Should have a comment |
||
|
||
test('fakeSyntheticFormEvent', () { | ||
var element = new DivElement(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need this try-catch, then, if it's not run in the DDC, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It throws even if the test isn't run 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, the contents of
setUpAll
are evaluated even when the group is disabled? Is that a test package bug?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's evaluated, I think the DDC might just be checking for instances of that being used, because it throws if it's in a test too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if I use
skip:
it's fine. So maybe it is a test package bug.