Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit c03c538

Browse files
committed
test(selector_spec): Do not test the order of directive instatiation.
BREAKING CHANGE: This relaxs the assumption that directives will be created in the same order everywhere. For #801
1 parent 5567eec commit c03c538

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/core_dom/selector_spec.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,14 @@ class DirectiveInfosMatcher extends Matcher {
234234
Map expectedTemplate;
235235
Map expectedComponent;
236236

237-
DirectiveInfosMatcher(this.expected, {this.expectedTemplate, this.expectedComponent});
237+
safeToString(a) => "${a['element']} ${a['selector']} ${a['value']}";
238+
safeToStringRef(a) => "${a.element} ${a.annotation.selector} ${a.value}";
239+
240+
DirectiveInfosMatcher(this.expected, {this.expectedTemplate, this.expectedComponent}) {
241+
if (expected != null) {
242+
expected.sort((a, b) => Comparable.compare(safeToString(a), safeToString(b)));
243+
}
244+
}
238245

239246
Description describe(Description description) =>
240247
description..add(expected.toString());
@@ -248,11 +255,12 @@ class DirectiveInfosMatcher extends Matcher {
248255
bool matches(ElementBinder binder, matchState) {
249256
var pass = true;
250257
if (expected != null) {
251-
pass = expected.length == binder.decorators.length;
258+
var decorators = new List.from(binder.decorators)
259+
..sort((a, b) => Comparable.compare(safeToStringRef(a), safeToStringRef(b)));
260+
pass = expected.length == decorators.length;
252261
for (var i = 0, ii = expected.length; i < ii; i++) {
253-
DirectiveRef directiveRef = binder.decorators[i];
262+
DirectiveRef directiveRef = decorators[i];
254263
var expectedMap = expected[i];
255-
256264
pass = pass && _refMatches(directiveRef, expectedMap);
257265
}
258266
}

0 commit comments

Comments
 (0)