From 7fd3a24cbce2ae9866f3eec6e7d9fb4e1ad81815 Mon Sep 17 00:00:00 2001 From: Arian Date: Fri, 12 Aug 2011 19:04:57 +0200 Subject: [PATCH] Add specs for #1116: `select.get('value')` on select elements where the option elements don't have the `value` attribute --- 1.4client/Element/Element.js | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/1.4client/Element/Element.js b/1.4client/Element/Element.js index bdd44af75..85b34734e 100644 --- a/1.4client/Element/Element.js +++ b/1.4client/Element/Element.js @@ -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', ''); + 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', ''); + 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', ''); + 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', ''); + 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', ''); + expect(form.getElement('select').get('value')).toEqual('two'); + }); + + }); + +});