aboutsummaryrefslogtreecommitdiffstats
path: root/scenario/widgets-scenario2.js
diff options
context:
space:
mode:
Diffstat (limited to 'scenario/widgets-scenario2.js')
-rw-r--r--scenario/widgets-scenario2.js54
1 files changed, 54 insertions, 0 deletions
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');
+ });
+});