added input#val method

Closes #237
This commit is contained in:
Di Peng 2011-06-05 11:44:28 -07:00 committed by Igor Minar
parent 1eebb771e3
commit 9fdb09ebf8
2 changed files with 16 additions and 1 deletions

View file

@ -171,6 +171,7 @@ angular.scenario.dsl('binding', function() {
* input(name).enter(value) enters value in input with specified name
* input(name).check() checks checkbox
* input(name).select(value) selects the radio button with specified name/value
* input(name).val() returns the value of the input.
*/
angular.scenario.dsl('input', function() {
var chain = {};
@ -201,6 +202,13 @@ angular.scenario.dsl('input', function() {
});
};
chain.val = function() {
return this.addFutureAction("return input val", function($window, $document, done) {
var input = $document.elements(':input[name="$1"]', this.name);
done(null,input.val());
});
};
return function(name) {
this.name = name;
return chain;

View file

@ -530,8 +530,15 @@ describe("angular.scenario.dsl", function() {
chain.select('foo');
expect($root.futureError).toMatch(/did not match/);
});
});
describe('val', function() {
it('should return value in text input', function() {
doc.append('<input name="test.input" value="something">');
$root.dsl.input('test.input').val();
expect($root.futureResult).toEqual("something");
});
});
});
describe('Textarea', function() {