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

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

Issue 1058283006: Update pubspecs and dependencies to get pkgbuild tests working. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
« no previous file with comments | « third_party/pkg/angular/lib/mock/probe.dart ('k') | third_party/pkg/angular/lib/mock/test_injection.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index ac1b5ddc8e653fddaa887a5a66272460a72ecc35..0000000000000000000000000000000000000000
--- a/third_party/pkg/angular/lib/mock/test_bed.dart
+++ /dev/null
@@ -1,91 +0,0 @@
-part of angular.mock;
-
-/**
- * Class which simplifies bootstraping of angular for unit tests.
- *
- * Simply inject [TestBed] into the test, then use [compile] to
- * match directives against the view.
- */
-class TestBed {
- final Injector injector;
- final Scope rootScope;
- final Compiler compiler;
- final Parser parser;
-
-
- Element rootElement;
- List<Node> rootElements;
- Block rootBlock;
-
- TestBed(this.injector, this.rootScope, this.compiler, this.parser);
-
-
- /**
- * Use to compile HTML and activate its directives.
- *
- * If [html] parameter is:
- *
- * - [String] then treat it as HTML
- * - [Node] then treat it as the root node
- * - [List<Node>] then treat it as a collection of nods
- *
- * After the compilation the [rootElements] contains an array of compiled root nodes,
- * and [rootElement] contains the first element from the [rootElemets].
- *
- * An option [scope] parameter can be supplied to link it with non root scope.
- */
- Element compile(html, {Scope scope, DirectiveMap directives}) {
- var injector = this.injector;
- if (scope != null) {
- injector = injector.createChild([new Module()..value(Scope, scope)]);
- }
- if (html is String) {
- rootElements = toNodeList(html);
- } else if (html is Node) {
- rootElements = [html];
- } else if (html is List<Node>) {
- rootElements = html;
- } else {
- throw 'Expecting: String, Node, or List<Node> got $html.';
- }
- rootElement = rootElements[0];
- if (directives == null) {
- directives = injector.get(DirectiveMap);
- }
- rootBlock = compiler(rootElements, directives)(injector, rootElements);
- return rootElement;
- }
-
- /**
- * Convert an [html] String to a [List] of [Element]s.
- */
- List<Element> toNodeList(html) {
- var div = new DivElement();
- div.setInnerHtml(html, treeSanitizer: new NullTreeSanitizer());
- var nodes = [];
- for (var node in div.nodes) {
- nodes.add(node);
- }
- return nodes;
- }
-
- /**
- * Triggern a specific DOM element on a given node to test directives
- * which listen to events.
- */
- 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();
- }
-
- /**
- * Select an [OPTION] in a [SELECT] with a given name and trigger the
- * appropriate DOM event. Used when testing [SELECT] controlls in forms.
- */
- selectOption(element, text) {
- element.querySelectorAll('option').forEach((o) => o.selected = o.text == text);
- triggerEvent(element, 'change');
- rootScope.apply();
- }
-}
« no previous file with comments | « third_party/pkg/angular/lib/mock/probe.dart ('k') | third_party/pkg/angular/lib/mock/test_injection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698