Skip to content

Commit 3ec837b

Browse files
committed
test(di): Add a test for sync binding + resolved async dependency
1 parent 18ff2be commit 3ec837b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

modules/angular2/test/di/async_spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function main() {
144144
.toThrowError('Cannot instantiate UserList synchronously. It is provided as a promise!');
145145
});
146146

147-
it('should throw when instantiating a sync binding with an dependency', function () {
147+
it('should throw when instantiating a sync binding with an async dependency', function () {
148148
var injector = new Injector([
149149
bind(UserList).toAsyncFactory(fetchUsers),
150150
UserController
@@ -154,6 +154,19 @@ export function main() {
154154
.toThrowError('Cannot instantiate UserList synchronously. It is provided as a promise! (UserController -> UserList)');
155155
});
156156

157+
it('should not throw when instantiating a sync binding with a resolved async dependency',
158+
inject([AsyncTestCompleter], (async) => {
159+
var injector = new Injector([
160+
bind(UserList).toAsyncFactory(fetchUsers),
161+
UserController
162+
]);
163+
164+
injector.asyncGet(UserList).then(() => {
165+
expect(() => { injector.get(UserController); }).not.toThrow();
166+
async.done();
167+
});
168+
}));
169+
157170
it('should resolve synchronously when an async dependency requested as a promise', function () {
158171
var injector = new Injector([
159172
bind(UserList).toAsyncFactory(fetchUsers),

0 commit comments

Comments
 (0)