Skip to content

Commit

Permalink
Add specs for #1116: select.get('value') on select elements where t…
Browse files Browse the repository at this point in the history
…he option elements don't have the `value` attribute
  • Loading branch information
Arian committed Aug 12, 2011
1 parent 1adb076 commit 7fd3a24
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions 1.4client/Element/Element.js
Expand Up @@ -16,3 +16,56 @@ describe('Element.getProperty', function(){
});

});

describe('Element.get', function(){

describe('value', function(){

it('should get the value of a option element when it does not have the value attribute', function(){
var select = new Element('select').set('html', '<option>s</option>');
expect(select.getElement('option').get('value')).toEqual('s');
});

it('should return the text of the selected option for a select element', function(){
var form = new Element('form');
form.set('html', '<select>\
<option>value 1</option>\
<option>value 2</option>\
<option selected>value 3</option>\
<option>value 4</option>\
</select>');
expect(form.getElement('select').get('value')).toEqual('value 3');
});

it('should return the text of the selected option for a multiple select element', function(){
var form = new Element('form');
form.set('html', '<select multiple>\
<option>value 1</option>\
<option selected>value 2</option>\
<option selected>value 3</option>\
<option>value 4</option>\
</select>');
expect(form.getElement('select').get('value')).toEqual('value 2');
});

it('should return the text of the first option of aselect element', function(){
var form = new Element('form');
form.set('html', '<select>\
<option>value 1</option>\
<option>value 2</option>\
</select>');
expect(form.getElement('select').get('value')).toEqual('value 1');
});

it('should return value of a select element', function(){
var form = new Element('form');
form.set('html', '<select multiple>\
<option value="one">value 1</option>\
<option selected value="two">value 2</option>\
</select>');
expect(form.getElement('select').get('value')).toEqual('two');
});

});

});

0 comments on commit 7fd3a24

Please sign in to comment.