From 5c887ddb66bdd0daa4f4a98af0c6e76d4aec0d70 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 2 Nov 2010 16:25:43 -0700 Subject: adding textarea() DSL for scenario runner --- CHANGELOG.md | 2 ++ src/scenario/dsl.js | 24 ++++++++++++++++++++++++ test/scenario/dslSpec.js | 16 ++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9baa3c..353ba9c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.9.2 faunal-mimicry (in-progress) # ### Testability +#### Scenario Runner - binding DSL in Scenario can now match bindings without specifying filters - dsl statements now accept a label argument to make test output more readable (issue #94) - dsl element() statement now implements most of the jQuery API (issue #106) @@ -8,6 +9,7 @@ - scenario runner is now compatible with IE8 (issue #93) - scenarior runner checks if URL would return a non-success status code (issue #100) - binding() DSL now accepts regular expressions +- new textarea() scenario runner DSL for entering text into textareas ### Breaking changes #### Scenario Runner diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js index 28e05724..cef024ad 100644 --- a/src/scenario/dsl.js +++ b/src/scenario/dsl.js @@ -217,6 +217,30 @@ angular.scenario.dsl('input', function() { }; }); + +/** + * Usage: + * textarea(name).enter(value) enters value in the text area with specified name + */ +angular.scenario.dsl('textarea', function() { + var chain = {}; + + chain.enter = function(value) { + return this.addFutureAction("textarea '" + this.name + "' enter '" + value + "'", function($window, $document, done) { + var textarea = $document.elements('textarea[name="$1"]', this.name); + textarea.val(value); + textarea.trigger('change'); + done(); + }); + }; + + return function(name) { + this.name = name; + return chain; + }; +}); + + /** * Usage: * repeater('#products table', 'Product List').count() number of rows diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index fd22303e..0338e884 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -486,5 +486,21 @@ describe("angular.scenario.dsl", function() { }); }); + + describe('Textarea', function() { + + it('should change value in textarea', function() { + doc.append(''); + var chain = $root.dsl.textarea('test.textarea'); + chain.enter('foo'); + expect(_jQuery('textarea[name="test.textarea"]').val()).toEqual('foo'); + }); + + it('should return error if no textarea exists', function() { + var chain = $root.dsl.input('test.textarea'); + chain.enter('foo'); + expect($root.futureError).toMatch(/did not match/); + }); + }); }); }); -- cgit v1.2.3