diff options
| author | Elliott Sprehn | 2010-10-19 13:17:49 -0700 |
|---|---|---|
| committer | Elliott Sprehn | 2010-10-20 14:38:00 -0700 |
| commit | 2115db69035c5993533fe7a3825e64cf6e9068ad (patch) | |
| tree | 796a502b28cd2bda8108a672eac0bf28c8bc21d4 /test/scenario/dslSpec.js | |
| parent | 9c8b1800b90e14b643bab6ada8e96f8f850e84a6 (diff) | |
| download | angular.js-2115db69035c5993533fe7a3825e64cf6e9068ad.tar.bz2 | |
Lots of stability and performance updates and UI polish too.
Polish the Scenario Runner UI to include:
- a scroll pane that steps appear in since the list can be very long
- Collapse successful tests
- Show the line where the DSL statements were when there's an error (Chrome, Firefox)
Also:
- Remove lots angular.bind calls to reduce the amount of stack space used.
- Use setTimeout(...,0) to schedule the next future to let the browser breathe and have it repaint the steps. Also prevents overflowing the stack when an it() creates many futures.
- Run afterEach() handlers even if the it() block fails.
- Make navigateTo() take a function as the second argument so you can compute a URL in the future.
- Add wait() DSL statement to allow interactive debugging of tests.
- Allow custom jQuery selectors with element(...).query(fn) DSL statement.
Known Issues:
- All afterEach() handlers run even if a beforeEach() handler fails. Only after handlers for the same level as the failure and above should run.
Diffstat (limited to 'test/scenario/dslSpec.js')
| -rw-r--r-- | test/scenario/dslSpec.js | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index dd489d86..0d523ad3 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -35,13 +35,16 @@ describe("angular.scenario.dsl", function() { document: _jQuery("<div></div>"), angular: new AngularMock() }; - $root = angular.scope({}, angular.service); + $root = angular.scope(); $root.futures = []; + $root.futureLog = []; + $root.$window = $window; $root.addFuture = function(name, fn) { this.futures.push(name); fn.call(this, function(error, result) { $root.futureError = error; $root.futureResult = result; + $root.futureLog.push(name); }); }; $root.dsl = {}; @@ -63,6 +66,18 @@ describe("angular.scenario.dsl", function() { SpecRunner.prototype.addFutureAction; }); + describe('Wait', function() { + it('should wait until resume to complete', function() { + expect($window.resume).toBeUndefined(); + $root.dsl.wait(); + expect(angular.isFunction($window.resume)).toBeTruthy(); + expect($root.futureLog).toEqual([]); + $window.resume(); + expect($root.futureLog). + toEqual(['waiting for you to call resume() in the console']); + }); + }); + describe('Pause', function() { beforeEach(function() { $root.setTimeout = function(fn, value) { @@ -99,10 +114,11 @@ describe("angular.scenario.dsl", function() { }); it('should allow a future url', function() { - var future = {name: 'future name', value: 'http://myurl'}; - $root.dsl.navigateTo(future); - expect($window.location).toEqual('http://myurl'); - expect($root.futureResult).toEqual('http://myurl'); + $root.dsl.navigateTo('http://myurl', function() { + return 'http://futureUrl/'; + }); + expect($window.location).toEqual('http://futureUrl/'); + expect($root.futureResult).toEqual('http://futureUrl/'); }); it('should complete if angular is missing from app frame', function() { @@ -205,6 +221,13 @@ describe("angular.scenario.dsl", function() { expect(doc.find('input').val()).toEqual('baz'); }); + it('should execute custom query', function() { + doc.append('<a id="test" href="myUrl"></a>'); + $root.dsl.element('#test').query(function(elements, done) { + done(null, elements.attr('href')); + }); + expect($root.futureResult).toEqual('myUrl'); + }); }); describe('Repeater', function() { |
