Skip to content

Commit aabe83c

Browse files
committed
chore(build): run application tests in Node
Closes angular#1423
1 parent fbd6851 commit aabe83c

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

gulpfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ var CONFIG = {
214214
}
215215
};
216216
CONFIG.test.js.cjs = CONFIG.test.js.cjs.map(function(s) {return CONFIG.dest.js.cjs + s});
217-
CONFIG.test.js.cjs.push('!**/core/application_spec.js'); //Disabled in nodejs because it relies on Zone.js
218217
CONFIG.test.js.cjs.push('!**/core/zone/vm_turn_zone_spec.js'); //Disabled in nodejs because it relies on Zone.js
219218
CONFIG.test.js.cjs.push('!**/render/dom/events/event_manager_spec.js'); //Disabled in nodejs because it relies on DOM events
220219

modules/angular2/src/core/testability/get_testability.es6

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
2+
import {global} from 'angular2/src/facade/lang';
23

34
class PublicTestability {
45
_testabililty: Testability;
@@ -18,18 +19,18 @@ class PublicTestability {
1819

1920
export class GetTestability {
2021
static addToWindow(registry: TestabilityRegistry) {
21-
if (!window.angular2) {
22-
window.angular2 = {};
22+
if (!global.angular2) {
23+
global.angular2 = {};
2324
}
24-
window.angular2.getTestability = function(elem): PublicTestability {
25+
global.angular2.getTestability = function(elem): PublicTestability {
2526
var testability = registry.findTestabilityInTree(elem);
2627

2728
if (testability == null) {
2829
throw new Error('Could not find testability for element.');
2930
}
3031
return new PublicTestability(testability);
3132
};
32-
window.angular2.resumeBootstrap = function() {
33+
global.angular2.resumeBootstrap = function() {
3334
// Intentionally left blank. This will allow Protractor to run
3435
// against angular2 without turning off Angular synchronization.
3536
};

modules/angular2/src/dom/parse5_adapter.cjs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,19 @@ export class Parse5DomAdapter extends DomAdapter {
370370
return this.isTemplateElement(el) ? this.content(el) : el;
371371
}
372372
createHtmlDocument() {
373-
throw _notImplemented('createHtmlDocument');
373+
var newDoc = treeAdapter.createDocument();
374+
newDoc.title = "fake title";
375+
var head = treeAdapter.createElement("head", null, []);
376+
var body = treeAdapter.createElement("body", 'http://www.w3.org/1999/xhtml', []);
377+
this.appendChild(newDoc, head);
378+
this.appendChild(newDoc, body);
379+
StringMapWrapper.set(newDoc, "head", head);
380+
StringMapWrapper.set(newDoc, "body", body);
381+
return newDoc;
374382
}
375383
defaultDoc() {
376384
if (defDoc === null) {
377-
defDoc = StringMapWrapper.create();
378-
defDoc.title = "Default title";
379-
StringMapWrapper.set(defDoc, "head", treeAdapter.createElement("head", null, []));
385+
defDoc = this.createHtmlDocument();
380386
}
381387
return defDoc;
382388
}

0 commit comments

Comments
 (0)