test(di): Add a test for sync binding + resolved async dependency
This commit is contained in:
parent
18ff2be9bb
commit
3ec837bfdb
15
modules/angular2/test/di/async_spec.js
vendored
15
modules/angular2/test/di/async_spec.js
vendored
@ -144,7 +144,7 @@ export function main() {
|
|||||||
.toThrowError('Cannot instantiate UserList synchronously. It is provided as a promise!');
|
.toThrowError('Cannot instantiate UserList synchronously. It is provided as a promise!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when instantiating a sync binding with an dependency', function () {
|
it('should throw when instantiating a sync binding with an async dependency', function () {
|
||||||
var injector = new Injector([
|
var injector = new Injector([
|
||||||
bind(UserList).toAsyncFactory(fetchUsers),
|
bind(UserList).toAsyncFactory(fetchUsers),
|
||||||
UserController
|
UserController
|
||||||
@ -154,6 +154,19 @@ export function main() {
|
|||||||
.toThrowError('Cannot instantiate UserList synchronously. It is provided as a promise! (UserController -> UserList)');
|
.toThrowError('Cannot instantiate UserList synchronously. It is provided as a promise! (UserController -> UserList)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not throw when instantiating a sync binding with a resolved async dependency',
|
||||||
|
inject([AsyncTestCompleter], (async) => {
|
||||||
|
var injector = new Injector([
|
||||||
|
bind(UserList).toAsyncFactory(fetchUsers),
|
||||||
|
UserController
|
||||||
|
]);
|
||||||
|
|
||||||
|
injector.asyncGet(UserList).then(() => {
|
||||||
|
expect(() => { injector.get(UserController); }).not.toThrow();
|
||||||
|
async.done();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should resolve synchronously when an async dependency requested as a promise', function () {
|
it('should resolve synchronously when an async dependency requested as a promise', function () {
|
||||||
var injector = new Injector([
|
var injector = new Injector([
|
||||||
bind(UserList).toAsyncFactory(fetchUsers),
|
bind(UserList).toAsyncFactory(fetchUsers),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user