From 3ec837bfdbeace1d0dc231e8c75abf08b7cdb7c8 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 25 Mar 2015 22:19:03 +0100 Subject: [PATCH] test(di): Add a test for sync binding + resolved async dependency --- modules/angular2/test/di/async_spec.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/angular2/test/di/async_spec.js b/modules/angular2/test/di/async_spec.js index 4f8b5ad23f..462006dfca 100644 --- a/modules/angular2/test/di/async_spec.js +++ b/modules/angular2/test/di/async_spec.js @@ -144,7 +144,7 @@ export function main() { .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([ bind(UserList).toAsyncFactory(fetchUsers), UserController @@ -154,6 +154,19 @@ export function main() { .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 () { var injector = new Injector([ bind(UserList).toAsyncFactory(fetchUsers),