diff options
| author | Igor Minar | 2010-11-02 16:25:43 -0700 |
|---|---|---|
| committer | Igor Minar | 2010-11-03 09:47:21 -0700 |
| commit | 5c887ddb66bdd0daa4f4a98af0c6e76d4aec0d70 (patch) | |
| tree | 7dfc3867d1832ec6e1562b5d99790aaaef48f7cc | |
| parent | 0bd4a473a717d5ed9b9c07fbdbc5c336beeef4e5 (diff) | |
| download | angular.js-5c887ddb66bdd0daa4f4a98af0c6e76d4aec0d70.tar.bz2 | |
adding textarea() DSL for scenario runner
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | src/scenario/dsl.js | 24 | ||||
| -rw-r--r-- | test/scenario/dslSpec.js | 16 |
3 files changed, 42 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9baa3c..353ba9c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # <angular/> 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('<textarea name="test.textarea">something</textarea>'); + 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/); + }); + }); }); }); |
