From aabe83cf6324cf404c94d8d9fc02e9ddc7c28ff9 Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Thu, 16 Apr 2015 18:44:34 +0200 Subject: [PATCH] chore(build): run application tests in Node Closes #1423 --- gulpfile.js | 1 - .../src/core/testability/get_testability.es6 | 9 +++++---- modules/angular2/src/dom/parse5_adapter.cjs | 14 ++++++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a10617f15c..5966f5c4fa 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -214,7 +214,6 @@ var CONFIG = { } }; CONFIG.test.js.cjs = CONFIG.test.js.cjs.map(function(s) {return CONFIG.dest.js.cjs + s}); -CONFIG.test.js.cjs.push('!**/core/application_spec.js'); //Disabled in nodejs because it relies on Zone.js CONFIG.test.js.cjs.push('!**/core/zone/vm_turn_zone_spec.js'); //Disabled in nodejs because it relies on Zone.js CONFIG.test.js.cjs.push('!**/render/dom/events/event_manager_spec.js'); //Disabled in nodejs because it relies on DOM events diff --git a/modules/angular2/src/core/testability/get_testability.es6 b/modules/angular2/src/core/testability/get_testability.es6 index c7c6555dbb..d8ff9d2b5a 100644 --- a/modules/angular2/src/core/testability/get_testability.es6 +++ b/modules/angular2/src/core/testability/get_testability.es6 @@ -1,4 +1,5 @@ import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability'; +import {global} from 'angular2/src/facade/lang'; class PublicTestability { _testabililty: Testability; @@ -18,10 +19,10 @@ class PublicTestability { export class GetTestability { static addToWindow(registry: TestabilityRegistry) { - if (!window.angular2) { - window.angular2 = {}; + if (!global.angular2) { + global.angular2 = {}; } - window.angular2.getTestability = function(elem): PublicTestability { + global.angular2.getTestability = function(elem): PublicTestability { var testability = registry.findTestabilityInTree(elem); if (testability == null) { @@ -29,7 +30,7 @@ export class GetTestability { } return new PublicTestability(testability); }; - window.angular2.resumeBootstrap = function() { + global.angular2.resumeBootstrap = function() { // Intentionally left blank. This will allow Protractor to run // against angular2 without turning off Angular synchronization. }; diff --git a/modules/angular2/src/dom/parse5_adapter.cjs b/modules/angular2/src/dom/parse5_adapter.cjs index e16136e34d..96c34394d4 100644 --- a/modules/angular2/src/dom/parse5_adapter.cjs +++ b/modules/angular2/src/dom/parse5_adapter.cjs @@ -370,13 +370,19 @@ export class Parse5DomAdapter extends DomAdapter { return this.isTemplateElement(el) ? this.content(el) : el; } createHtmlDocument() { - throw _notImplemented('createHtmlDocument'); + var newDoc = treeAdapter.createDocument(); + newDoc.title = "fake title"; + var head = treeAdapter.createElement("head", null, []); + var body = treeAdapter.createElement("body", 'http://www.w3.org/1999/xhtml', []); + this.appendChild(newDoc, head); + this.appendChild(newDoc, body); + StringMapWrapper.set(newDoc, "head", head); + StringMapWrapper.set(newDoc, "body", body); + return newDoc; } defaultDoc() { if (defDoc === null) { - defDoc = StringMapWrapper.create(); - defDoc.title = "Default title"; - StringMapWrapper.set(defDoc, "head", treeAdapter.createElement("head", null, [])); + defDoc = this.createHtmlDocument(); } return defDoc; }