11import { ddescribe , describe , it , iit , xit , expect , beforeEach } from 'test_lib/test_lib' ;
2- import { Injector , Inject , InjectFuture , bind , Key } from 'di/di' ;
3- import { Future , FutureWrapper } from 'facade/async' ;
2+ import { Injector , Inject , InjectPromise , bind , Key } from 'di/di' ;
3+ import { Promise , PromiseWrapper } from 'facade/async' ;
44
55class UserList {
66}
77
88function fetchUsers ( ) {
9- return FutureWrapper . value ( new UserList ( ) ) ;
9+ return PromiseWrapper . resolve ( new UserList ( ) ) ;
1010}
1111
1212class SynchronousUserList {
@@ -19,7 +19,7 @@ class UserController {
1919}
2020
2121class AsyncUserController {
22- constructor ( @InjectFuture ( UserList ) userList ) {
22+ constructor ( @InjectPromise ( UserList ) userList ) {
2323 this . userList = userList ;
2424 }
2525}
@@ -28,28 +28,28 @@ export function main() {
2828 describe ( "async injection" , function ( ) {
2929
3030 describe ( "asyncGet" , function ( ) {
31- it ( 'should return a future ' , function ( ) {
31+ it ( 'should return a promise ' , function ( ) {
3232 var injector = new Injector ( [
3333 bind ( UserList ) . toAsyncFactory ( fetchUsers )
3434 ] ) ;
3535 var p = injector . asyncGet ( UserList ) ;
36- expect ( p ) . toBeFuture ( ) ;
36+ expect ( p ) . toBePromise ( ) ;
3737 } ) ;
3838
39- it ( 'should return a future when the binding is sync' , function ( ) {
39+ it ( 'should return a promise when the binding is sync' , function ( ) {
4040 var injector = new Injector ( [
4141 SynchronousUserList
4242 ] ) ;
4343 var p = injector . asyncGet ( SynchronousUserList ) ;
44- expect ( p ) . toBeFuture ( ) ;
44+ expect ( p ) . toBePromise ( ) ;
4545 } ) ;
4646
47- it ( "should return a future when the binding is sync (from cache)" , function ( ) {
47+ it ( "should return a promise when the binding is sync (from cache)" , function ( ) {
4848 var injector = new Injector ( [
4949 UserList
5050 ] ) ;
5151 expect ( injector . get ( UserList ) ) . toBeAnInstanceOf ( UserList ) ;
52- expect ( injector . asyncGet ( UserList ) ) . toBeFuture ( ) ;
52+ expect ( injector . asyncGet ( UserList ) ) . toBePromise ( ) ;
5353 } ) ;
5454
5555 it ( 'should return the injector' , function ( done ) {
@@ -61,7 +61,7 @@ export function main() {
6161 } ) ;
6262 } ) ;
6363
64- it ( 'should return a future when instantiating a sync binding ' +
64+ it ( 'should return a promise when instantiating a sync binding ' +
6565 'with an async dependency' , function ( done ) {
6666 var injector = new Injector ( [
6767 bind ( UserList ) . toAsyncFactory ( fetchUsers ) ,
@@ -83,7 +83,7 @@ export function main() {
8383 var ul1 = injector . asyncGet ( UserList ) ;
8484 var ul2 = injector . asyncGet ( UserList ) ;
8585
86- FutureWrapper . wait ( [ ul1 , ul2 ] ) . then ( function ( uls ) {
86+ PromiseWrapper . all ( [ ul1 , ul2 ] ) . then ( function ( uls ) {
8787 expect ( uls [ 0 ] ) . toBe ( uls [ 1 ] ) ;
8888 done ( ) ;
8989 } ) ;
@@ -94,13 +94,13 @@ export function main() {
9494 UserList
9595 ] ) ;
9696
97- var future = injector . asyncGet ( UserList ) ;
97+ var promise = injector . asyncGet ( UserList ) ;
9898 var ul = injector . get ( UserList ) ;
9999
100- expect ( future ) . toBeFuture ( ) ;
100+ expect ( promise ) . toBePromise ( ) ;
101101 expect ( ul ) . toBeAnInstanceOf ( UserList ) ;
102102
103- future . then ( function ( ful ) {
103+ promise . then ( function ( ful ) {
104104 expect ( ful ) . toBe ( ul ) ;
105105 done ( ) ;
106106 } ) ;
@@ -114,8 +114,8 @@ export function main() {
114114 } )
115115 ] ) ;
116116
117- var future = injector . asyncGet ( UserController ) ;
118- FutureWrapper . catchError ( future , function ( e ) {
117+ var promise = injector . asyncGet ( UserController ) ;
118+ PromiseWrapper . then ( promise , null , function ( e ) {
119119 expect ( e . message ) . toContain ( "Error during instantiation of UserList! (UserController -> UserList)" ) ;
120120 done ( ) ;
121121 } ) ;
@@ -129,7 +129,7 @@ export function main() {
129129 ] ) ;
130130
131131 expect ( ( ) => injector . get ( UserList ) )
132- . toThrowError ( 'Cannot instantiate UserList synchronously. It is provided as a future !' ) ;
132+ . toThrowError ( 'Cannot instantiate UserList synchronously. It is provided as a promise !' ) ;
133133 } ) ;
134134
135135 it ( 'should throw when instantiating a sync binding with an dependency' , function ( ) {
@@ -139,29 +139,29 @@ export function main() {
139139 ] ) ;
140140
141141 expect ( ( ) => injector . get ( UserController ) )
142- . toThrowError ( 'Cannot instantiate UserList synchronously. It is provided as a future ! (UserController -> UserList)' ) ;
142+ . toThrowError ( 'Cannot instantiate UserList synchronously. It is provided as a promise ! (UserController -> UserList)' ) ;
143143 } ) ;
144144
145- it ( 'should resolve synchronously when an async dependency requested as a future ' , function ( ) {
145+ it ( 'should resolve synchronously when an async dependency requested as a promise ' , function ( ) {
146146 var injector = new Injector ( [
147147 bind ( UserList ) . toAsyncFactory ( fetchUsers ) ,
148148 AsyncUserController
149149 ] ) ;
150150 var controller = injector . get ( AsyncUserController ) ;
151151
152152 expect ( controller ) . toBeAnInstanceOf ( AsyncUserController ) ;
153- expect ( controller . userList ) . toBeFuture ( ) ;
153+ expect ( controller . userList ) . toBePromise ( ) ;
154154 } ) ;
155155
156- it ( 'should wrap sync dependencies into futures if required' , function ( ) {
156+ it ( 'should wrap sync dependencies into promises if required' , function ( ) {
157157 var injector = new Injector ( [
158158 bind ( UserList ) . toFactory ( ( ) => new UserList ( ) ) ,
159159 AsyncUserController
160160 ] ) ;
161161 var controller = injector . get ( AsyncUserController ) ;
162162
163163 expect ( controller ) . toBeAnInstanceOf ( AsyncUserController ) ;
164- expect ( controller . userList ) . toBeFuture ( ) ;
164+ expect ( controller . userList ) . toBePromise ( ) ;
165165 } ) ;
166166 } ) ;
167167 } ) ;
0 commit comments