diff options
| author | Andres Ornelas | 2010-06-09 16:05:51 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-06-09 16:05:51 -0700 |
| commit | bbb45a7eed5264a343c191f3abfbe6f6b5d51139 (patch) | |
| tree | 340453d4268200f36a7934274450502145e123cf /src | |
| parent | 36b58b235eeca4e9580162a697d8a96c41263ebc (diff) | |
| parent | d0a468153d98c892323cb135b509cb46f67e44fd (diff) | |
| download | angular.js-bbb45a7eed5264a343c191f3abfbe6f6b5d51139.tar.bz2 | |
Merge branch 'repeater'
Diffstat (limited to 'src')
| -rw-r--r-- | src/scenario/DSL.js | 31 | ||||
| -rw-r--r-- | src/scenario/Runner.js | 15 |
2 files changed, 30 insertions, 16 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js index b318e99c..194a28d6 100644 --- a/src/scenario/DSL.js +++ b/src/scenario/DSL.js @@ -2,7 +2,7 @@ angular.scenario.dsl.browser = { navigateTo: function(url){ $scenario.addStep('Navigate to: ' + url, function(done){ var self = this; - self.testFrame.load(function(){ + this.testFrame.load(function(){ self.testFrame.unbind(); self.testWindow = self.testFrame[0].contentWindow; self.testDocument = jQuery(self.testWindow.document); @@ -11,7 +11,7 @@ angular.scenario.dsl.browser = { self.notifyWhenNoOutstandingRequests(done); }); if (this.testFrame.attr('src') == url) { - this.testWindow.location.reload(); + this.testFrame[0].contentWindow.location.reload(); } else { this.testFrame.attr('src', url); } @@ -44,17 +44,20 @@ angular.scenario.dsl.input = function(selector) { }; }; -angular.scenario.dsl.expect = function(selector) { - return { - toEqual: function(expected) { - $scenario.addStep("Expect that " + selector + " equals '" + expected + "'", function(done){ - var attrName = selector.substring(2, selector.length - 2); - var binding = this.testDocument.find('span[ng-bind=' + attrName + ']'); - if (binding.text() != expected) { - this.result.fail("Expected '" + expected + "' but was '" + binding.text() + "'"); +angular.scenario.dsl.expect = { + repeater: function(selector) { + return { + count: { + toEqual: function(number) { + $scenario.addStep("Expect that there are " + number + " items in Repeater with selector '" + selector + "'", function(done) { + var items = this.testDocument.find(selector); + if (items.length != number) { + this.result.fail("Expected " + number + " but was " + items.length); + } + done(); + }); } - done(); - }); - } - }; + } + }; + } }; diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js index da6e2c39..8e0cc909 100644 --- a/src/scenario/Runner.js +++ b/src/scenario/Runner.js @@ -8,23 +8,34 @@ angular.scenario.Runner = function(scope, jQuery){ var specs = this.specs = {}; var path = []; - this.scope.describe = function describe(name, body){ + this.scope.describe = function(name, body){ path.push(name); body(); path.pop(); }; - this.scope.it = function it(name, body) { + var beforeEach = noop; + var afterEach = noop; + this.scope.beforeEach = function(body) { + beforeEach = body; + }; + this.scope.afterEach = function(body) { + afterEach = body; + }; + this.scope.it = function(name, body) { var specName = path.join(' ') + ': it ' + name; self.currentSpec = specs[specName] = { name: specName, steps:[] }; try { + beforeEach(); body(); } catch(err) { self.addStep(err.message || 'ERROR', function(){ throw err; }); + } finally { + afterEach(); } self.currentSpec = null; }; |
