- Why it works?
- Need to obtain Deferred instance for testing part from the target.
test('bad use (1) of jsdeferred with qunit.', function(){ var x = 0; Deferred.define(); next(function(){ next(function(){ x = 1; }); }) .next(function(){ equals(x, 0); start(); }); stop(100); }); test('bad use (2) of jsdeferred with qunit.', function(){ var x = 0; Deferred.define(); next(function(){ return next(function(){ x = 1; }); }); next(function(){ equals(x, 0); start(); }); stop(100); }); test('right way: some thing bit complex using jsdeferred with qunit.', function(){ var x = 0; var d = Deferred.define(); d.next(function(){ debug('first next '); return next(function(){ debug('nested next'); x = 1; }); }) .next(function(){ debug('equals next '); equals(x, 1); start(); }); stop(100); });
0 件のコメント:
コメントを投稿