Skip to content

Commit 78428d9

Browse files
committed
WIP: fix(test): fix basic test setup
1 parent 4054abd commit 78428d9

File tree

62 files changed

+472
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+472
-452
lines changed

karma-js.conf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function(config) {
1111
files: [
1212
// Sources and specs.
1313
// Loaded through the System loader, in `test-main.js`.
14-
{pattern: 'dist/js/dev/es5/**', included: false, watched: false},
14+
{pattern: 'dist/@angular/**/*.js', included: false, watched: false},
1515

1616
'node_modules/es6-shim/es6-shim.js',
1717
// include Angular v1 for upgrade module testing
@@ -30,10 +30,10 @@ module.exports = function(config) {
3030
'node_modules/reflect-metadata/Reflect.js',
3131
'tools/build/file2modulename.js',
3232
'test-main.js',
33-
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false}
33+
{pattern: 'modules/@angular/testing/test/static_assets/**', included: false, watched: false}
3434
],
3535

36-
exclude: ['dist/js/dev/es5/**/e2e_test/**', 'dist/js/dev/es5/angular2/examples/**', 'dist/angular1_router.js'],
36+
exclude: ['dist/@angular/**/e2e_test/**', 'dist/@angular/examples/**', 'dist/angular1_router.js', 'dist/@angular/testing/src/e2e_util.js'],
3737

3838
customLaunchers: browserProvidersConf.customLaunchers,
3939

modules/@angular/common/test/directives/ng_if_spec.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
xit,
1313
} from '@angular/testing/testing_internal';
1414

15-
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
15+
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
1616

1717
import {Component} from '@angular/core';
1818
import {NgIf} from '@angular/common';
@@ -29,7 +29,7 @@ export function main() {
2929
.createAsync(TestComponent)
3030
.then((fixture) => {
3131
fixture.detectChanges();
32-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
32+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
3333
.toEqual(1);
3434
expect(fixture.debugElement.nativeElement).toHaveText('hello');
3535
async.done();
@@ -45,7 +45,7 @@ export function main() {
4545
.createAsync(TestComponent)
4646
.then((fixture) => {
4747
fixture.detectChanges();
48-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
48+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
4949
.toEqual(1);
5050
expect(fixture.debugElement.nativeElement).toHaveText('hello2');
5151
async.done();
@@ -61,19 +61,19 @@ export function main() {
6161
.then((fixture) => {
6262
fixture.debugElement.componentInstance.booleanCondition = false;
6363
fixture.detectChanges();
64-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
64+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
6565
.toEqual(0);
6666
expect(fixture.debugElement.nativeElement).toHaveText('');
6767

6868
fixture.debugElement.componentInstance.booleanCondition = true;
6969
fixture.detectChanges();
70-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
70+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
7171
.toEqual(1);
7272
expect(fixture.debugElement.nativeElement).toHaveText('hello');
7373

7474
fixture.debugElement.componentInstance.booleanCondition = false;
7575
fixture.detectChanges();
76-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
76+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
7777
.toEqual(0);
7878
expect(fixture.debugElement.nativeElement).toHaveText('');
7979

@@ -91,31 +91,31 @@ export function main() {
9191
.then((fixture) => {
9292
fixture.debugElement.componentInstance.booleanCondition = false;
9393
fixture.detectChanges();
94-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
94+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
9595
.toEqual(0);
9696
expect(fixture.debugElement.nativeElement).toHaveText('');
9797

9898
fixture.debugElement.componentInstance.booleanCondition = true;
9999
fixture.detectChanges();
100-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
100+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
101101
.toEqual(1);
102102
expect(fixture.debugElement.nativeElement).toHaveText('hello');
103103

104104
fixture.debugElement.componentInstance.nestedBooleanCondition = false;
105105
fixture.detectChanges();
106-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
106+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
107107
.toEqual(0);
108108
expect(fixture.debugElement.nativeElement).toHaveText('');
109109

110110
fixture.debugElement.componentInstance.nestedBooleanCondition = true;
111111
fixture.detectChanges();
112-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
112+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
113113
.toEqual(1);
114114
expect(fixture.debugElement.nativeElement).toHaveText('hello');
115115

116116
fixture.debugElement.componentInstance.booleanCondition = false;
117117
fixture.detectChanges();
118-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
118+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
119119
.toEqual(0);
120120
expect(fixture.debugElement.nativeElement).toHaveText('');
121121

@@ -136,21 +136,21 @@ export function main() {
136136
.createAsync(TestComponent)
137137
.then((fixture) => {
138138
fixture.detectChanges();
139-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
139+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
140140
.toEqual(3);
141-
expect(DOM.getText(fixture.debugElement.nativeElement))
141+
expect(getDOM().getText(fixture.debugElement.nativeElement))
142142
.toEqual('helloNumberhelloStringhelloFunction');
143143

144144
fixture.debugElement.componentInstance.numberCondition = 0;
145145
fixture.detectChanges();
146-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
146+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
147147
.toEqual(1);
148148
expect(fixture.debugElement.nativeElement).toHaveText('helloString');
149149

150150
fixture.debugElement.componentInstance.numberCondition = 1;
151151
fixture.debugElement.componentInstance.stringCondition = "bar";
152152
fixture.detectChanges();
153-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
153+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
154154
.toEqual(1);
155155
expect(fixture.debugElement.nativeElement).toHaveText('helloNumber');
156156
async.done();
@@ -167,13 +167,13 @@ export function main() {
167167
.createAsync(TestComponent)
168168
.then((fixture) => {
169169
fixture.detectChanges();
170-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
170+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
171171
.toEqual(1);
172172
expect(fixture.debugElement.nativeElement).toHaveText('hello');
173173

174174
fixture.debugElement.componentInstance.numberCondition = 2;
175175
fixture.detectChanges();
176-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
176+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
177177
.toEqual(1);
178178
expect(fixture.debugElement.nativeElement).toHaveText('hello');
179179

@@ -189,13 +189,13 @@ export function main() {
189189
.createAsync(TestComponent)
190190
.then((fixture) => {
191191
fixture.detectChanges();
192-
DOM.addClass(DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'),
192+
getDOM().addClass(getDOM().querySelector(fixture.debugElement.nativeElement, 'copy-me'),
193193
"foo");
194194

195195
fixture.debugElement.componentInstance.numberCondition = 2;
196196
fixture.detectChanges();
197197
expect(
198-
DOM.hasClass(DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'),
198+
getDOM().hasClass(getDOM().querySelector(fixture.debugElement.nativeElement, 'copy-me'),
199199
"foo"))
200200
.toBe(true);
201201

@@ -213,7 +213,7 @@ export function main() {
213213
.createAsync(TestComponent)
214214
.then((fixture) => {
215215
expect(() => fixture.detectChanges()).toThrowError();
216-
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
216+
expect(getDOM().querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
217217
.toEqual(0);
218218
expect(fixture.debugElement.nativeElement).toHaveText('');
219219
async.done();

modules/@angular/common/test/directives/ng_style_spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {StringMapWrapper} from '@angular/facade';
1818

1919
import {Component} from '@angular/core';
2020

21-
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
21+
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
2222
import {NgStyle} from '@angular/common/src/directives/ng_style';
2323

2424
export function main() {
@@ -32,7 +32,7 @@ export function main() {
3232
.createAsync(TestComponent)
3333
.then((fixture) => {
3434
fixture.detectChanges();
35-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
35+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
3636
.toEqual('40px');
3737

3838
async.done();
@@ -50,13 +50,13 @@ export function main() {
5050

5151
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
5252
fixture.detectChanges();
53-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
53+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
5454
.toEqual('40px');
5555

5656
expr = fixture.debugElement.componentInstance.expr;
5757
expr['max-width'] = '30%';
5858
fixture.detectChanges();
59-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
59+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
6060
.toEqual('30%');
6161

6262
async.done();
@@ -72,12 +72,12 @@ export function main() {
7272
.then((fixture) => {
7373
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
7474
fixture.detectChanges();
75-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
75+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
7676
.toEqual('40px');
7777

7878
StringMapWrapper.delete(fixture.debugElement.componentInstance.expr, 'max-width');
7979
fixture.detectChanges();
80-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
80+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
8181
.toEqual('');
8282

8383
async.done();
@@ -93,16 +93,16 @@ export function main() {
9393
.then((fixture) => {
9494
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
9595
fixture.detectChanges();
96-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
96+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
9797
.toEqual('40px');
98-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
98+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
9999
.toEqual('12px');
100100

101101
StringMapWrapper.delete(fixture.debugElement.componentInstance.expr, 'max-width');
102102
fixture.detectChanges();
103-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
103+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
104104
.toEqual('');
105-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
105+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
106106
.toEqual('12px');
107107

108108
async.done();
@@ -118,17 +118,17 @@ export function main() {
118118
.then((fixture) => {
119119
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
120120
fixture.detectChanges();
121-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
121+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
122122
.toEqual('40px');
123-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
123+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
124124
.toEqual('12px');
125125

126126
StringMapWrapper.delete(fixture.debugElement.componentInstance.expr, 'max-width');
127-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
127+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'font-size'))
128128
.toEqual('12px');
129129

130130
fixture.detectChanges();
131-
expect(DOM.getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
131+
expect(getDOM().getStyle(fixture.debugElement.children[0].nativeElement, 'max-width'))
132132
.toEqual('');
133133

134134
async.done();

modules/@angular/common/test/directives/non_bindable_spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
it,
1212
xit,
1313
} from '@angular/testing/testing_internal';
14-
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
14+
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
1515
import {Component, Directive} from '@angular/core';
1616
import {ElementRef} from '@angular/core/src/linker/element_ref';
1717

@@ -37,10 +37,10 @@ export function main() {
3737
.then((fixture) => {
3838
fixture.detectChanges();
3939

40-
// We must use DOM.querySelector instead of fixture.query here
40+
// We must use getDOM().querySelector instead of fixture.query here
4141
// since the elements inside are not compiled.
42-
var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
43-
expect(DOM.hasClass(span, 'compiled')).toBeFalsy();
42+
var span = getDOM().querySelector(fixture.debugElement.nativeElement, '#child');
43+
expect(getDOM().hasClass(span, 'compiled')).toBeFalsy();
4444
async.done();
4545
});
4646
}));
@@ -52,8 +52,8 @@ export function main() {
5252
.createAsync(TestComponent)
5353
.then((fixture) => {
5454
fixture.detectChanges();
55-
var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
56-
expect(DOM.hasClass(span, 'compiled')).toBeTruthy();
55+
var span = getDOM().querySelector(fixture.debugElement.nativeElement, '#child');
56+
expect(getDOM().hasClass(span, 'compiled')).toBeTruthy();
5757
async.done();
5858
});
5959
}));
@@ -62,7 +62,7 @@ export function main() {
6262

6363
@Directive({selector: '[test-dec]'})
6464
class TestDirective {
65-
constructor(el: ElementRef) { DOM.addClass(el.nativeElement, 'compiled'); }
65+
constructor(el: ElementRef) { getDOM().addClass(el.nativeElement, 'compiled'); }
6666
}
6767

6868
@Component({selector: 'test-cmp', directives: [TestDirective], template: ''})

modules/@angular/common/test/forms/integration_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
browserDetection
2020
} from '@angular/testing/testing_internal';
2121

22-
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
22+
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
2323
import {
2424
Control,
2525
ControlGroup,
@@ -1250,8 +1250,8 @@ export function main() {
12501250
// In Firefox, effective text selection in the real DOM requires an actual focus
12511251
// of the field. This is not an issue in a new HTML document.
12521252
if (browserDetection.isFirefox) {
1253-
var fakeDoc = DOM.createHtmlDocument();
1254-
DOM.appendChild(fakeDoc.body, fixture.debugElement.nativeElement);
1253+
var fakeDoc = getDOM().createHtmlDocument();
1254+
getDOM().appendChild(fakeDoc.body, fixture.debugElement.nativeElement);
12551255
}
12561256

12571257
var input = fixture.debugElement.query(By.css("input")).nativeElement;
@@ -1405,7 +1405,7 @@ class MyComp {
14051405
}
14061406

14071407
function sortedClassList(el) {
1408-
var l = DOM.classList(el);
1408+
var l = getDOM().classList(el);
14091409
ListWrapper.sort(l);
14101410
return l;
14111411
}

modules/@angular/common/test/pipes/async_pipe_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
PromiseWrapper,
2323
TimerWrapper
2424
} from '@angular/facade';
25-
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
25+
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
2626
import {PromiseCompleter} from '@angular/facade';
2727

2828
export function main() {
@@ -121,7 +121,7 @@ export function main() {
121121
var completer: PromiseCompleter<any>;
122122
var ref: SpyChangeDetectorRef;
123123
// adds longer timers for passing tests in IE
124-
var timer = (!isBlank(DOM) && browserDetection.isIE) ? 50 : 10;
124+
var timer = (!isBlank(getDOM()) && browserDetection.isIE) ? 50 : 10;
125125

126126
beforeEach(() => {
127127
completer = PromiseWrapper.completer();

modules/@angular/compiler/src/schema/dom_element_schema_registry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import {Injectable} from '@angular/core';
23
import {ElementSchemaRegistry} from './element_schema_registry';
34

modules/@angular/compiler/test/offline_compiler_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {ComponentFactory} from '@angular/core/src/linker/component_factory';
2222
import * as typed from './offline_compiler_codegen_typed';
2323
import * as untyped from './offline_compiler_codegen_untyped';
2424

25-
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
25+
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
2626
import {SharedStylesHost} from '@angular/platform-browser/src/dom/shared_styles_host';
2727

2828
import {CompA} from './offline_compiler_util';
@@ -32,13 +32,13 @@ export function main() {
3232
var typedComponentFactory = typed.CompANgFactory;
3333
var untypedComponentFactory = untyped.CompANgFactory;
3434

35-
if (IS_DART || !DOM.supportsDOMEvents()) {
35+
if (IS_DART || !getDOM().supportsDOMEvents()) {
3636
// Our generator only works on node.js and Dart...
3737
outputDefs.push({'compAHostComponentFactory': typedComponentFactory, 'name': 'typed'});
3838
}
3939
if (!IS_DART) {
4040
// Our generator only works on node.js and Dart...
41-
if (!DOM.supportsDOMEvents()) {
41+
if (!getDOM().supportsDOMEvents()) {
4242
outputDefs.push({'compAHostComponentFactory': untypedComponentFactory, 'name': 'untyped'});
4343
}
4444
}

0 commit comments

Comments
 (0)