Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1193)

Unified Diff: third_party/pkg/angular/lib/mock/test_bed.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/lib/mock/test_bed.dart
diff --git a/third_party/pkg/angular/lib/mock/test_bed.dart b/third_party/pkg/angular/lib/mock/test_bed.dart
index af5882cc34f59984d8b0621f5b5ab24292edaa57..ac1b5ddc8e653fddaa887a5a66272460a72ecc35 100644
--- a/third_party/pkg/angular/lib/mock/test_bed.dart
+++ b/third_party/pkg/angular/lib/mock/test_bed.dart
@@ -34,9 +34,9 @@ class TestBed {
*
* An option [scope] parameter can be supplied to link it with non root scope.
*/
- Element compile(html, {Scope scope}) {
+ Element compile(html, {Scope scope, DirectiveMap directives}) {
var injector = this.injector;
- if(scope != null) {
+ if (scope != null) {
injector = injector.createChild([new Module()..value(Scope, scope)]);
}
if (html is String) {
@@ -49,7 +49,10 @@ class TestBed {
throw 'Expecting: String, Node, or List<Node> got $html.';
}
rootElement = rootElements[0];
- rootBlock = compiler(rootElements)(injector, rootElements);
+ if (directives == null) {
+ directives = injector.get(DirectiveMap);
+ }
+ rootBlock = compiler(rootElements, directives)(injector, rootElements);
return rootElement;
}
@@ -60,7 +63,7 @@ class TestBed {
var div = new DivElement();
div.setInnerHtml(html, treeSanitizer: new NullTreeSanitizer());
var nodes = [];
- for(var node in div.nodes) {
+ for (var node in div.nodes) {
nodes.add(node);
}
return nodes;
@@ -72,6 +75,8 @@ class TestBed {
*/
triggerEvent(element, name, [type='MouseEvent']) {
element.dispatchEvent(new Event.eventType(type, name));
+ // Since we are manually triggering event we need to simpulate apply();
+ rootScope.apply();
}
/**
@@ -81,5 +86,6 @@ class TestBed {
selectOption(element, text) {
element.querySelectorAll('option').forEach((o) => o.selected = o.text == text);
triggerEvent(element, 'change');
+ rootScope.apply();
}
}

Powered by Google App Engine
This is Rietveld 408576698