Skip to content

Commit b4f55ae

Browse files
committed
chore(package): test against angular2 beta.17
- Update devDependencies - Directly import zone modules - Adapt to breaking changes of testing
1 parent cb5579f commit b4f55ae

File tree

6 files changed

+65
-65
lines changed

6 files changed

+65
-65
lines changed

karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = function(config) {
1515

1616
// list of files / patterns to load in the browser
1717
files: [
18-
'node_modules/zone.js/dist/zone-microtask.js',
1918
'test/integration/init.js',
2019
'test/integration/*.spec.js'
2120
],

package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,39 @@
2727
"author": "Shuhei Kagawa <shuhei.kagawa@gmail.com>",
2828
"license": "ISC",
2929
"devDependencies": {
30-
"angular2": "^2.0.0-beta.7",
31-
"babel-cli": "^6.3.17",
32-
"babel-core": "^6.3.17",
33-
"babel-eslint": "^5.0.0-beta6",
30+
"angular2": "2.0.0-beta.17",
31+
"babel-cli": "^6.7.7",
32+
"babel-core": "^6.7.7",
33+
"babel-eslint": "^6.0.4",
3434
"babel-plugin-external-helpers-2": "^6.3.13",
35-
"babel-plugin-transform-class-properties": "^6.3.13",
36-
"babel-plugin-transform-decorators-legacy": "^1.3.3",
37-
"babel-plugin-transform-flow-strip-types": "^6.3.15",
38-
"babel-polyfill": "^6.3.14",
39-
"babel-preset-es2015": "^6.3.13",
40-
"babelify": "^7.2.0",
41-
"babylon": "^6.3.20",
35+
"babel-plugin-transform-class-properties": "^6.6.0",
36+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
37+
"babel-plugin-transform-flow-strip-types": "^6.7.0",
38+
"babel-polyfill": "^6.7.4",
39+
"babel-preset-es2015": "^6.6.0",
40+
"babelify": "^7.3.0",
41+
"babylon": "^6.7.0",
4242
"browserify": "^13.0.0",
43-
"es6-promise": "^3.0.2",
44-
"es6-shim": "^0.33.0",
45-
"eslint": "^2.2.0",
43+
"es6-promise": "^3.1.2",
44+
"es6-shim": "0.35.0",
45+
"eslint": "^2.8.0",
4646
"jasmine-core": "^2.4.1",
47-
"karma": "^0.13.15",
48-
"karma-browserify": "^5.0.2",
49-
"karma-jasmine": "^0.3.6",
47+
"karma": "^0.13.22",
48+
"karma-browserify": "^5.0.4",
49+
"karma-jasmine": "^0.3.8",
5050
"karma-phantomjs-launcher": "^1.0.0",
5151
"karma-source-map-support": "^1.1.0",
52-
"phantomjs-prebuilt": "^2.1.3",
52+
"phantomjs-prebuilt": "^2.1.7",
5353
"reflect-metadata": "0.1.2",
54-
"rxjs": "5.0.0-beta.2",
55-
"tape": "^4.2.2",
54+
"rxjs": "5.0.0-beta.6",
55+
"tape": "^4.5.1",
5656
"watchify": "^3.7.0",
57-
"zone.js": "0.5.15"
57+
"zone.js": "0.6.12"
5858
},
5959
"peerDependencies": {
60-
"babel-plugin-transform-decorators-legacy": "^1.3.3"
60+
"babel-plugin-transform-decorators-legacy": "^1.3.4"
6161
},
6262
"dependencies": {
63-
"babel-generator": "^6.3.26"
63+
"babel-generator": "^6.7.7"
6464
}
6565
}

test/integration/component.spec.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import {
55
ViewMetadata
66
} from 'angular2/core';
77
import {
8-
AsyncTestCompleter,
98
beforeEach,
109
describe,
1110
expect,
1211
inject,
1312
it,
14-
TestComponentBuilder,
15-
} from 'angular2/testing_internal';
13+
async,
14+
TestComponentBuilder
15+
} from 'angular2/testing';
1616

1717
describe('component', () => {
18-
it('works with class/prop/param decorators and type annotations', inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
18+
it('works with class/prop/param decorators and type annotations', async(inject([TestComponentBuilder], (tcb) => {
1919
class Greeter {
2020
say(greeting, name) {
2121
return `${greeting}, ${name}!`;
@@ -53,8 +53,6 @@ describe('component', () => {
5353

5454
fixture.detectChanges();
5555
expect(fixture.debugElement.nativeElement).toHaveText('Hello, Babel!');
56-
async.done();
57-
})
58-
.catch((e) => console.error(e));
59-
}));
56+
});
57+
})));
6058
});

test/integration/init.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import 'reflect-metadata';
22
import 'babel-polyfill';
33

4+
import 'zone.js/dist/zone';
5+
import 'zone.js/dist/long-stack-trace-zone';
6+
import 'zone.js/dist/jasmine-patch';
7+
import 'zone.js/dist/async-test';
8+
import 'zone.js/dist/fake-async-test';
9+
410
import {setBaseTestProviders} from 'angular2/testing';
511
import {
612
TEST_BROWSER_PLATFORM_PROVIDERS,

test/integration/parameter-decorator-alternative.spec.js

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Injector, Injectable, provide,
2+
ReflectiveInjector, Injectable, provide,
33
Component, Directive,
44
QueryList,
55
AttributeMetadata, QueryMetadata, ViewQueryMetadata,
@@ -10,20 +10,23 @@ import {
1010
NgFor
1111
} from 'angular2/common';
1212
import {
13-
AsyncTestCompleter,
1413
beforeEach,
1514
describe,
1615
expect,
1716
inject,
1817
it,
1918
xit,
19+
async,
2020
TestComponentBuilder,
21-
} from 'angular2/testing_internal';
21+
} from 'angular2/testing';
2222

2323
describe('parameter decorator alternatives', () => {
2424
describe('Directive DI', () => {
25-
it('works as @Attribute', inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
26-
@Directive({ selector: 'foo' })
25+
it('works as @Attribute', async(inject([TestComponentBuilder], (tcb) => {
26+
@Component({
27+
selector: 'foo',
28+
template: '{{bar}}'
29+
})
2730
@Reflect.metadata('parameters', [[new AttributeMetadata('bar')]])
2831
class Foo {
2932
constructor(barProp) {
@@ -42,12 +45,10 @@ describe('parameter decorator alternatives', () => {
4245
.then((fixture) => {
4346
const foo = fixture.debugElement.children[0].componentInstance;
4447
expect(foo.bar).toEqual('baz');
45-
46-
async.done();
4748
});
48-
}));
49+
})));
4950

50-
it('works as @Query', inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
51+
it('works as @Query', async(inject([TestComponentBuilder], (tcb) => {
5152
@Component({
5253
selector: 'pane',
5354
inputs: ['title'],
@@ -62,7 +63,7 @@ describe('parameter decorator alternatives', () => {
6263
directives: [NgFor],
6364
template: `
6465
<ul>
65-
<li *ngFor="#pane of panes">{{pane.title}}</li>
66+
<li *ngFor="let pane of panes">{{pane.title}}</li>
6667
</ul>
6768
<ng-content></ng-content>
6869
`
@@ -80,7 +81,7 @@ describe('parameter decorator alternatives', () => {
8081
template: `
8182
<tabs>
8283
<pane title="Overview">...</pane>
83-
<pane *ngFor="#o of objects" [title]="o.title">{{o.text}}</pane>
84+
<pane *ngFor="let o of objects" [title]="o.title">{{o.text}}</pane>
8485
</tabs>
8586
`
8687
})
@@ -101,12 +102,10 @@ describe('parameter decorator alternatives', () => {
101102
expect([...listItems].map((l) => l.textContent)).toEqual(['Overview', 'foo', 'bar', 'baz']);
102103
const panes = tabs.nativeElement.querySelectorAll('div');
103104
expect([...panes].map((p) => p.textContent)).toEqual(['...', 'Foo!', 'Bar!', 'Baz!']);
104-
105-
async.done();
106105
});
107-
}));
106+
})));
108107

109-
it('works as @ViewQuery', inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
108+
it('works as @ViewQuery', async(inject([TestComponentBuilder], (tcb) => {
110109
@Component({
111110
selector: 'item',
112111
template: '<ng-content></ng-content>'
@@ -134,19 +133,20 @@ describe('parameter decorator alternatives', () => {
134133
const items = fixture.componentInstance.items;
135134
items.changes.subscribe(() => {
136135
expect(items.length).toEqual(3);
137-
138-
async.done();
139136
});
140137

141138
fixture.detectChanges();
142139
});
143-
}));
140+
})));
144141

145-
it('works as @Host', inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
142+
it('works as @Host', async(inject([TestComponentBuilder], (tcb) => {
146143
class OtherService {}
147144
class HostService {}
148145

149-
@Directive({ selector: 'child-directive' })
146+
@Component({
147+
selector: 'child-directive',
148+
template: 'child'
149+
})
150150
@Reflect.metadata('parameters', [
151151
[new OptionalMetadata(), new HostMetadata()],
152152
[new OptionalMetadata(), new HostMetadata()]
@@ -183,12 +183,9 @@ describe('parameter decorator alternatives', () => {
183183
const parent = fixture.debugElement.children[0];
184184
const childInstance = parent.children[0].componentInstance;
185185
expect(childInstance.os).toBeNull();
186-
expect(childInstance.hs).toBeAnInstanceOf(HostService)
187-
188-
async.done();
189-
})
190-
.catch((e) => console.error(e));
191-
}));
186+
expect(childInstance.hs).toBeAnInstanceOf(HostService);
187+
});
188+
})));
192189
});
193190

194191
describe('Pure DI', () => {
@@ -203,7 +200,7 @@ describe('parameter decorator alternatives', () => {
203200
}
204201
}
205202

206-
const injector = Injector.resolveAndCreate([
203+
const injector = ReflectiveInjector.resolveAndCreate([
207204
provide('MyEngine', { useClass: Engine }),
208205
Car
209206
]);
@@ -222,7 +219,7 @@ describe('parameter decorator alternatives', () => {
222219
}
223220
}
224221

225-
const injector = Injector.resolveAndCreate([Car]);
222+
const injector = ReflectiveInjector.resolveAndCreate([Car]);
226223

227224
expect(injector.get(Car).engine).toBeNull();
228225
}));
@@ -238,10 +235,10 @@ describe('parameter decorator alternatives', () => {
238235
}
239236
}
240237

241-
const injector = Injector.resolveAndCreate([Dependency, NeedsDependency]);
238+
const injector = ReflectiveInjector.resolveAndCreate([Dependency, NeedsDependency]);
242239
expect(injector.get(NeedsDependency).dependency).toBeAnInstanceOf(Dependency);
243240

244-
const parent= Injector.resolveAndCreate([Dependency]);
241+
const parent= ReflectiveInjector.resolveAndCreate([Dependency]);
245242
const child= parent.resolveAndCreateChild([NeedsDependency]);
246243
expect(() => child.get(NeedsDependency)).toThrowError();
247244
}));
@@ -257,10 +254,10 @@ describe('parameter decorator alternatives', () => {
257254
}
258255
}
259256

260-
const injector = Injector.resolveAndCreate([Dependency, NeedsDependency]);
257+
const injector = ReflectiveInjector.resolveAndCreate([Dependency, NeedsDependency]);
261258
expect(() => injector.get(NeedsDependency)).toThrowError();
262259

263-
const parent= Injector.resolveAndCreate([Dependency]);
260+
const parent= ReflectiveInjector.resolveAndCreate([Dependency]);
264261
const child= parent.resolveAndCreateChild([NeedsDependency]);
265262
expect(child.get(NeedsDependency).dependency).toBeAnInstanceOf(Dependency);
266263
}));

test/integration/reflection.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
describe,
33
expect,
44
it
5-
} from 'angular2/testing_internal';
5+
} from 'angular2/testing';
66

77
import {
88
EventEmitter,

0 commit comments

Comments
 (0)