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

Commit

Permalink
test(selector_spec): Do not test the order of directive instatiation.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This relaxs the assumption that directives will
be created in the same order everywhere.

For #801
  • Loading branch information
jbdeboer committed Apr 10, 2014
1 parent 5567eec commit c03c538
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/core_dom/selector_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,14 @@ class DirectiveInfosMatcher extends Matcher {
Map expectedTemplate;
Map expectedComponent;

DirectiveInfosMatcher(this.expected, {this.expectedTemplate, this.expectedComponent});
safeToString(a) => "${a['element']} ${a['selector']} ${a['value']}";
safeToStringRef(a) => "${a.element} ${a.annotation.selector} ${a.value}";

DirectiveInfosMatcher(this.expected, {this.expectedTemplate, this.expectedComponent}) {
if (expected != null) {
expected.sort((a, b) => Comparable.compare(safeToString(a), safeToString(b)));
}
}

Description describe(Description description) =>
description..add(expected.toString());
Expand All @@ -248,11 +255,12 @@ class DirectiveInfosMatcher extends Matcher {
bool matches(ElementBinder binder, matchState) {
var pass = true;
if (expected != null) {
pass = expected.length == binder.decorators.length;
var decorators = new List.from(binder.decorators)
..sort((a, b) => Comparable.compare(safeToStringRef(a), safeToStringRef(b)));
pass = expected.length == decorators.length;
for (var i = 0, ii = expected.length; i < ii; i++) {
DirectiveRef directiveRef = binder.decorators[i];
DirectiveRef directiveRef = decorators[i];
var expectedMap = expected[i];

pass = pass && _refMatches(directiveRef, expectedMap);
}
}
Expand Down

0 comments on commit c03c538

Please sign in to comment.