diff options
| author | Misko Hevery | 2010-05-20 15:55:41 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-05-20 15:55:41 -0700 |
| commit | 5215e2095cfd42a0363eb02eded34e03fa2b0cd3 (patch) | |
| tree | 01ce02f1c5b7e544a6266d9a6f3b63a5184e88c8 /scenario | |
| parent | 31b35b141f52e6f5d3805d6ca4f2702aee05d61d (diff) | |
| download | angular.js-5215e2095cfd42a0363eb02eded34e03fa2b0cd3.tar.bz2 | |
basic end to end runner
Diffstat (limited to 'scenario')
| -rw-r--r-- | scenario/Runner.html | 3 | ||||
| -rw-r--r-- | scenario/widgets-scenario2.js | 54 | ||||
| -rw-r--r-- | scenario/widgets-scenarios.js | 22 | ||||
| -rw-r--r-- | scenario/widgets.html | 3 |
4 files changed, 67 insertions, 15 deletions
diff --git a/scenario/Runner.html b/scenario/Runner.html index c5eb6205..5502283a 100644 --- a/scenario/Runner.html +++ b/scenario/Runner.html @@ -2,8 +2,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/javascript" src="../src/scenario/bootstrap.js"></script> - <script type="text/javascript" src="widgets-scenarios.js"></script> - <script type="text/javascript" src="datastore-scenarios.js"></script> + <script type="text/javascript" src="widgets-scenario2.js"></script> </head> <body> </body> diff --git a/scenario/widgets-scenario2.js b/scenario/widgets-scenario2.js new file mode 100644 index 00000000..e24cabad --- /dev/null +++ b/scenario/widgets-scenario2.js @@ -0,0 +1,54 @@ +browser = { + navigateTo: function(url){ + $scenario.addStep('Navigate to: ' + url, function(done){ + var self = this; + self.testFrame.load(function(){ + self.testFrame.unbind(); + self.testDocument = self.testWindow.angular.element(self.testWindow.document); + done(); + }); + if (this.testFrame.attr('src') == url) { + this.testWindow.location.reload(); + } else { + this.testFrame.attr('src', url); + } + }); + } +}; + +function input(selector) { + return { + enter: function(value){ + $scenario.addStep("Set input text of '" + selector + "' to value '" + value + "'", function(done){ + var input = this.testDocument.find('input[name=' + selector + ']'); + input.val(value); + input.trigger('change'); + done(); + }); + } + }; +} + +function expect(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() + "'"); + } + done(); + }); + } + }; +} + +describe('widgets', function(){ + it('should verify that basic widgets work', function(){ + browser.navigateTo('widgets.html'); + expect('{{text.basic}}').toEqual(''); + input('text.basic').enter('John'); + expect('{{text.basic}}').toEqual('JohnXX'); + }); +}); diff --git a/scenario/widgets-scenarios.js b/scenario/widgets-scenarios.js index 663b06da..a1e6c0ed 100644 --- a/scenario/widgets-scenarios.js +++ b/scenario/widgets-scenarios.js @@ -3,28 +3,28 @@ angular.scenarioDef.widgets = { {Given:"browser", at:"widgets.html"} ], checkWidgetBinding:[ - {Then:"text", at:"{{name}}", should_be:""}, - {When:"enter", text:"John", at:":input[name=name]"}, - {Then:"text", at:"{{name}}", should_be:"John"}, - - {Then:"text", at:"{{gender}}", should_be:""}, - {When:"click", at:"input:radio[value=male]"}, + {Then:"text", at:"{{text.basic}}", should_be:""}, + {When:"enter", text:"John", at:":input[name=text.basic]"}, + {Then:"text", at:"{{text.basic}}", should_be:"John"}, + {Then:"text", at:"{{gender}}", should_be:"male"}, - + {When:"click", at:"input:radio[value=female]"}, + {Then:"text", at:"{{gender}}", should_be:"female"}, + {Then:"text", at:"{{tea}}", should_be:"on"}, {When:"click", at:"input[name=tea]"}, {Then:"text", at:"{{tea}}", should_be:""}, - + {Then:"text", at:"{{coffee}}", should_be:""}, {When:"click", at:"input[name=coffee]"}, {Then:"text", at:"{{coffee}}", should_be:"on"}, - + {Then:"text", at:"{{count}}", should_be:0}, {When:"click", at:"form :button"}, {When:"click", at:"form :submit"}, {When:"click", at:"form :image"}, {Then:"text", at:"{{count}}", should_be:3}, - + {Then:"text", at:"{{select}}", should_be:"A"}, {When:"select", at:"select[name=select]", option:"B"}, {Then:"text", at:"{{select}}", should_be:"B"}, @@ -36,7 +36,7 @@ angular.scenarioDef.widgets = { {Then:"text", at:"{{multiple}}", should_be:["A", "B"]}, {When:"select", at:"select[name=multiple]", option:"A"}, {Then:"text", at:"{{multiple}}", should_be:["B"]}, - + {Then:"text", at:"{{hidden}}", should_be:"hiddenValue"}, {Then:"text", at:"{{password}}", should_be:"passwordValue"}, diff --git a/scenario/widgets.html b/scenario/widgets.html index 242fd9e6..5c3afa21 100644 --- a/scenario/widgets.html +++ b/scenario/widgets.html @@ -16,8 +16,7 @@ <tr> <td>basic</td> <td> - <input type="text" name="text.basic" ng-required ng-validate="number" ng-format="number"/> - <input type="text" name="text.basic" ng-format="number"/> + <input type="text" name="text.basic"/> </td> <td>text.basic={{text.basic}}</td> </tr> |
