diff options
| author | Andres Ornelas | 2010-06-09 14:12:54 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-06-09 14:12:54 -0700 |
| commit | 85fac4d78c131771d7fdd46d6ccd44bae92419cd (patch) | |
| tree | f15243a5a71b5c363acba11781f9bd83e2435b2f /test/scenario/RunnerSpec.js | |
| parent | f6a405c283ba1f2e0037e0bedb52e5cee618d4ff (diff) | |
| download | angular.js-85fac4d78c131771d7fdd46d6ccd44bae92419cd.tar.bz2 | |
add beforeEach and afterEach to scenario DSL
Diffstat (limited to 'test/scenario/RunnerSpec.js')
| -rw-r--r-- | test/scenario/RunnerSpec.js | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js index 030bdc06..ca6e8eb2 100644 --- a/test/scenario/RunnerSpec.js +++ b/test/scenario/RunnerSpec.js @@ -14,6 +14,8 @@ describe('Runner', function(){ body = _jQuery('<div></div>'); runner = new angular.scenario.Runner(scenario, _jQuery); Describe = scenario.describe; + BeforeEach = scenario.beforeEach; + AfterEach = scenario.afterEach; It = scenario.it; $scenario = scenario.$scenario; }); @@ -36,7 +38,10 @@ describe('Runner', function(){ expect(spec.name).toEqual('describe name: it should text'); }); - it('should complain on duplicate it', angular.noop); + it('should complain on duplicate it', function() { + // WRITE ME!!!! + }); + it('should create a failing step if there is a javascript error', function(){ var spec; Describe('D1', function(){ @@ -55,6 +60,39 @@ describe('Runner', function(){ }; }); }); + + describe('beforeEach', function() { + it('should execute beforeEach before every it', function() { + Describe('describe name', function(){ + BeforeEach(logger('before;')); + It('should text', logger('body;')); + It('should text2', logger('body2;')); + }); + expect(log).toEqual('before;body;before;body2;'); + }); + }); + describe('afterEach', function() { + it('should execute afterEach after every it', function() { + Describe('describe name', function(){ + AfterEach(logger('after;')); + It('should text', logger('body;')); + It('should text2', logger('body2;')); + }); + expect(log).toEqual('body;after;body2;after;'); + }); + + it('should always execute afterEach after every it', function() { + Describe('describe name', function(){ + AfterEach(logger('after;')); + It('should text', function() { + log = 'body;'; + throw "MyError"; + }); + It('should text2', logger('body2;')); + }); + expect(log).toEqual('body;after;body2;after;'); + }); + }); }); describe('steps building', function(){ |
