diff options
| author | Andres Ornelas | 2010-06-30 09:51:54 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-06-30 09:51:54 -0700 |
| commit | 9d8646b0d1bee2ca60bbb7b494b63ab83e243072 (patch) | |
| tree | fb78e3b93cce33aec11450235e9fd5f83e1a14ab /test/scenario/RunnerSpec.js | |
| parent | e664186f93838ca1fb1b2e4277f7c18264f81d92 (diff) | |
| download | angular.js-9d8646b0d1bee2ca60bbb7b494b63ab83e243072.tar.bz2 | |
all tests passing with new futures concept
Diffstat (limited to 'test/scenario/RunnerSpec.js')
| -rw-r--r-- | test/scenario/RunnerSpec.js | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js index 884e897a..689354df 100644 --- a/test/scenario/RunnerSpec.js +++ b/test/scenario/RunnerSpec.js @@ -34,7 +34,7 @@ describe('Runner', function(){ }); expect(log).toEqual('body'); var spec = $scenario.specs['describe name: it should text']; - expect(spec.steps).toEqual([]); + expect(spec.futures).toEqual([]); expect(spec.name).toEqual('describe name: it should text'); }); @@ -42,7 +42,7 @@ describe('Runner', function(){ // WRITE ME!!!! }); - it('should create a failing step if there is a javascript error', function(){ + it('should create a failing future if there is a javascript error', function(){ var spec; Describe('D1', function(){ It('I1', function(){ @@ -50,10 +50,10 @@ describe('Runner', function(){ throw {message: 'blah'}; }); }); - var step = spec.steps[0]; - expect(step.name).toEqual('blah'); + var future = spec.futures[0]; + expect(future.name).toEqual('blah'); try { - step.fn(); + future.behavior(); fail(); } catch (e) { expect(e.message).toEqual('blah'); @@ -97,60 +97,61 @@ describe('Runner', function(){ var next; Describe('describe name', function(){ AfterEach(function() { - $scenario.addStep('afterEachLog', logger('after;')); - $scenario.addStep('afterEachThrow', function() { + $scenario.addFuture('afterEachLog', logger('after;')); + $scenario.addFuture('afterEachThrow', function() { throw "AfterError"; }); }); It('should text1', function() { - $scenario.addStep('step1', logger('step1;')); + $scenario.addFuture('future1', logger('future1;')); }); It('should text2', function() { - $scenario.addStep('step2', logger('step2;')); + $scenario.addFuture('future2', logger('future2;')); }); }); $scenario.run(body); - expect(log).toEqual('step1;after;step2;after;'); + expect(log).toEqual('future1;after;future2;after;'); expect(scenario.$testrun.results).toEqual([ { name : 'describe name: it should text1', passed : false, error : 'AfterError', - steps : [ 'step1', 'afterEachLog', 'afterEachThrow' ] }, + steps : [ 'future1', 'afterEachLog', 'afterEachThrow' ] }, { name : 'describe name: it should text2', passed : false, error : 'AfterError', - steps : [ 'step2', 'afterEachLog', 'afterEachThrow' ] }]); + steps : [ 'future2', 'afterEachLog', 'afterEachThrow' ] }]); }); }); }); - describe('steps building', function(){ - it('should queue steps', function(){ - function step(){}; + describe('future building', function(){ + it('should queue futures', function(){ + function behavior(){}; Describe('name', function(){ It('should', function(){ - $scenario.addStep('stepname', step); + $scenario.addFuture('futureName', behavior); }); }); - expect($scenario.specs['name: it should'].steps).toEqual([{name:'stepname', fn:step}]); + expect($scenario.specs['name: it should'].futures[0].name). + toEqual('futureName'); }); }); describe('execution', function(){ - it('should execute the queued steps', function(){ + it('should execute the queued futures', function(){ var next, firstThis, secondThis, doneThis, spec; $scenario.specs['spec'] = { - steps: [ - {name:'step1', fn: function(done) { - next = done; - log += 'first;'; - firstThis = this; - }}, - {name:'step2', fn:function(done){ - next = done; - log += 'second;'; - secondThis = this; - }} + futures: [ + new Future('future1', function(done) { + next = done; + log += 'first;'; + firstThis = this; + }), + new Future('future2', function(done) { + next = done; + log += 'second;'; + secondThis = this; + }) ] }; @@ -174,18 +175,18 @@ describe('Runner', function(){ expect(spec.result.passed).toEqual(true); }); - it('should handle exceptions in a step', function(){ + it('should handle exceptions in a future', function(){ $scenario.specs['spec'] = { - steps: [ - {name: 'first step', fn: function(done) { + futures: [ + new Future('first future', function(done) { done(); - }}, - {name:'error', fn:function(done) { + }), + new Future('error', function(done) { throw "MyError"; - }}, - {name: 'should not execute', fn: function(done) { + }), + new Future('should not execute', function(done) { done(); - }} + }) ] }; @@ -199,7 +200,7 @@ describe('Runner', function(){ name: 'spec', passed: false, error: 'MyError', - steps: ['first step', 'error']}]); + steps: ['first future', 'error']}]); }); }); @@ -207,15 +208,15 @@ describe('Runner', function(){ var next; beforeEach(function() { Describe('d1', function(){ - It('it1', function(){ $scenario.addStep('s1', logger('s1,')); }); + It('it1', function(){ $scenario.addFuture('s1', logger('s1,')); }); It('it2', function(){ - $scenario.addStep('s2', logger('s2,')); - $scenario.addStep('s2.2', function(done){ next = done; }); + $scenario.addFuture('s2', logger('s2,')); + $scenario.addFuture('s2.2', function(done){ next = done; }); }); }); Describe('d2', function(){ - It('it3', function(){ $scenario.addStep('s3', logger('s3,')); }); - It('it4', function(){ $scenario.addStep('s4', logger('s4,')); }); + It('it3', function(){ $scenario.addFuture('s3', logger('s3,')); }); + It('it4', function(){ $scenario.addFuture('s4', logger('s4,')); }); }); }); it('should execute all specs', function(){ @@ -231,15 +232,15 @@ describe('Runner', function(){ $scenario.run(body); expect(scenario.$testrun.done).toBeFalsy(); expect(scenario.$testrun.results).toEqual([ - {name: 'd1: it it1', passed: true, steps: ['s1']} + {name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']} ]); next(); expect(scenario.$testrun.done).toBeTruthy(); expect(scenario.$testrun.results).toEqual([ - {name: 'd1: it it1', passed: true, steps: ['s1']}, - {name: 'd1: it it2', passed: true, steps: ['s2', 's2.2']}, - {name: 'd2: it it3', passed: true, steps: ['s3']}, - {name: 'd2: it it4', passed: true, steps: ['s4']} + {name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']}, + {name: 'd1: it it2', passed: true, error: undefined, steps: ['s2', 's2.2']}, + {name: 'd2: it it3', passed: true, error: undefined, steps: ['s3']}, + {name: 'd2: it it4', passed: true, error: undefined, steps: ['s4']} ]); }); }); |
