@@ -41,16 +41,16 @@ suite('Async', () => {
4141 return result ;
4242 } ) ;
4343
44- test ( 'Cancel callback behaviour' , async function ( ) {
45- let withCancelCallback = new TPromise ( ( ) => { } , ( ) => { } ) ;
46- let withoutCancelCallback = new TPromise ( ( ) => { } ) ;
44+ // test('Cancel callback behaviour', async function () {
45+ // let withCancelCallback = new WinJsPromise (() => { }, () => { });
46+ // let withoutCancelCallback = new TPromise(() => { });
4747
48- withCancelCallback . cancel ( ) ;
49- withoutCancelCallback . cancel ( ) ;
48+ // withCancelCallback.cancel();
49+ // ( withoutCancelCallback as WinJsPromise) .cancel();
5050
51- await withCancelCallback . then ( undefined , err => { assert . ok ( isPromiseCanceledError ( err ) ) ; } ) ;
52- await withoutCancelCallback . then ( undefined , err => { assert . ok ( isPromiseCanceledError ( err ) ) ; } ) ;
53- } ) ;
51+ // await withCancelCallback.then(undefined, err => { assert.ok(isPromiseCanceledError(err)); });
52+ // await withoutCancelCallback.then(undefined, err => { assert.ok(isPromiseCanceledError(err)); });
53+ // });
5454
5555 // Cancelling a sync cancelable promise will fire the cancelled token.
5656 // Also, every `then` callback runs in another execution frame.
@@ -97,49 +97,49 @@ suite('Async', () => {
9797 return promise . then ( ( ) => assert . deepEqual ( order , [ 'in callback' , 'afterCreate' , 'cancelled' , 'afterCancel' , 'finally' ] ) ) ;
9898 } ) ;
9999
100- // Cancelling a sync tpromise will NOT cancel the promise, since it has resolved already.
101- // Every `then` callback runs sync in the same execution frame, thus `finally` executes
102- // before `afterCancel`.
103- test ( 'TPromise execution order (sync)' , function ( ) {
104- const order = [ ] ;
105- let promise = new TPromise ( resolve => {
106- order . push ( 'in executor' ) ;
107- resolve ( 1234 ) ;
108- } , ( ) => order . push ( 'cancelled' ) ) ;
100+ // // Cancelling a sync tpromise will NOT cancel the promise, since it has resolved already.
101+ // // Every `then` callback runs sync in the same execution frame, thus `finally` executes
102+ // // before `afterCancel`.
103+ // test('TPromise execution order (sync)', function () {
104+ // const order = [];
105+ // let promise = new WinJsPromise (resolve => {
106+ // order.push('in executor');
107+ // resolve(1234);
108+ // }, () => order.push('cancelled'));
109109
110- order . push ( 'afterCreate' ) ;
110+ // order.push('afterCreate');
111111
112- promise = promise
113- . then ( null , err => null )
114- . then ( ( ) => order . push ( 'finally' ) ) ;
112+ // promise = promise
113+ // .then(null, err => null)
114+ // .then(() => order.push('finally'));
115115
116- promise . cancel ( ) ;
117- order . push ( 'afterCancel' ) ;
116+ // promise.cancel();
117+ // order.push('afterCancel');
118118
119- return promise . then ( ( ) => assert . deepEqual ( order , [ 'in executor' , 'afterCreate' , 'finally' , 'afterCancel' ] ) ) ;
120- } ) ;
119+ // return promise.then(() => assert.deepEqual(order, ['in executor', 'afterCreate', 'finally', 'afterCancel']));
120+ // });
121121
122- // Cancelling an async tpromise will cancel the promise.
123- // Every `then` callback runs sync on the same execution frame as the `cancel` call,
124- // so finally still executes before `afterCancel`.
125- test ( 'TPromise execution order (async)' , function ( ) {
126- const order = [ ] ;
127- let promise = new TPromise ( resolve => {
128- order . push ( 'in executor' ) ;
129- setTimeout ( ( ) => resolve ( 1234 ) ) ;
130- } , ( ) => order . push ( 'cancelled' ) ) ;
122+ // // Cancelling an async tpromise will cancel the promise.
123+ // // Every `then` callback runs sync on the same execution frame as the `cancel` call,
124+ // // so finally still executes before `afterCancel`.
125+ // test('TPromise execution order (async)', function () {
126+ // const order = [];
127+ // let promise = new WinJsPromise (resolve => {
128+ // order.push('in executor');
129+ // setTimeout(() => resolve(1234));
130+ // }, () => order.push('cancelled'));
131131
132- order . push ( 'afterCreate' ) ;
132+ // order.push('afterCreate');
133133
134- promise = promise
135- . then ( null , err => null )
136- . then ( ( ) => order . push ( 'finally' ) ) ;
134+ // promise = promise
135+ // .then(null, err => null)
136+ // .then(() => order.push('finally'));
137137
138- promise . cancel ( ) ;
139- order . push ( 'afterCancel' ) ;
138+ // promise.cancel();
139+ // order.push('afterCancel');
140140
141- return promise . then ( ( ) => assert . deepEqual ( order , [ 'in executor' , 'afterCreate' , 'cancelled' , 'finally' , 'afterCancel' ] ) ) ;
142- } ) ;
141+ // return promise.then(() => assert.deepEqual(order, ['in executor', 'afterCreate', 'cancelled', 'finally', 'afterCancel']));
142+ // });
143143
144144 test ( 'cancelablePromise - get inner result' , async function ( ) {
145145 let promise = async . createCancelablePromise ( token => {
@@ -190,63 +190,6 @@ suite('Async', () => {
190190 } ) ;
191191 } ) ;
192192
193- test ( 'Throttler - cancel should not cancel other promises' , function ( ) {
194- let count = 0 ;
195- let factory = ( ) => TPromise . wrap ( async . timeout ( 0 ) ) . then ( ( ) => ++ count ) ;
196-
197- let throttler = new async . Throttler ( ) ;
198- let p1 : TPromise ;
199-
200- const p = TPromise . join ( [
201- p1 = throttler . queue ( factory ) . then ( ( result ) => { assert ( false , 'should not be here, 1' ) ; } , ( ) => { assert ( true , 'yes, it was cancelled' ) ; } ) ,
202- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 1 ) ; } , ( ) => { assert ( false , 'should not be here, 2' ) ; } ) ,
203- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 1 ) ; } , ( ) => { assert ( false , 'should not be here, 3' ) ; } ) ,
204- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 1 ) ; } , ( ) => { assert ( false , 'should not be here, 4' ) ; } )
205- ] ) ;
206-
207- p1 . cancel ( ) ;
208-
209- return p ;
210- } ) ;
211-
212- test ( 'Throttler - cancel the first queued promise should not cancel other promises' , function ( ) {
213- let count = 0 ;
214- let factory = ( ) => TPromise . wrap ( async . timeout ( 0 ) ) . then ( ( ) => ++ count ) ;
215-
216- let throttler = new async . Throttler ( ) ;
217- let p2 : TPromise ;
218-
219- const p = TPromise . join ( [
220- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 1 ) ; } , ( ) => { assert ( false , 'should not be here, 1' ) ; } ) ,
221- p2 = throttler . queue ( factory ) . then ( ( result ) => { assert ( false , 'should not be here, 2' ) ; } , ( ) => { assert ( true , 'yes, it was cancelled' ) ; } ) ,
222- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 2 ) ; } , ( ) => { assert ( false , 'should not be here, 3' ) ; } ) ,
223- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 2 ) ; } , ( ) => { assert ( false , 'should not be here, 4' ) ; } )
224- ] ) ;
225-
226- p2 . cancel ( ) ;
227-
228- return p ;
229- } ) ;
230-
231- test ( 'Throttler - cancel in the middle should not cancel other promises' , function ( ) {
232- let count = 0 ;
233- let factory = ( ) => TPromise . wrap ( async . timeout ( 0 ) ) . then ( ( ) => ++ count ) ;
234-
235- let throttler = new async . Throttler ( ) ;
236- let p3 : TPromise ;
237-
238- const p = TPromise . join ( [
239- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 1 ) ; } , ( ) => { assert ( false , 'should not be here, 1' ) ; } ) ,
240- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 2 ) ; } , ( ) => { assert ( false , 'should not be here, 2' ) ; } ) ,
241- p3 = throttler . queue ( factory ) . then ( ( result ) => { assert ( false , 'should not be here, 3' ) ; } , ( ) => { assert ( true , 'yes, it was cancelled' ) ; } ) ,
242- throttler . queue ( factory ) . then ( ( result ) => { assert . equal ( result , 2 ) ; } , ( ) => { assert ( false , 'should not be here, 4' ) ; } )
243- ] ) ;
244-
245- p3 . cancel ( ) ;
246-
247- return p ;
248- } ) ;
249-
250193 test ( 'Throttler - last factory should be the one getting called' , function ( ) {
251194 let factoryFactory = ( n : number ) => ( ) => {
252195 return TPromise . wrap ( async . timeout ( 0 ) ) . then ( ( ) => n ) ;
0 commit comments