@@ -197,14 +197,32 @@ describe("Test for simple form models", function() {
197197
198198 it ( "should reset the value of radio set field" , function ( ) {
199199 var fieldModel = new FieldModel ( ) ;
200- var element = jasmine . createSpyObj ( 'element' , [ 'removeAttr' , 'removeClass' , 'show' , 'attr' , 'is' , 'find' , 'val' ] ) ;
200+ var element = jasmine . createSpyObj ( 'element' , [ 'removeAttr' , 'removeClass' , 'show' , 'attr' , 'is' , 'find' , 'val' ] ) ;
201201 fieldModel . element = element ;
202202 element . find = jasmine . createSpy ( 'find() spy' ) . and . returnValue ( [ ] ) ;
203203 element . attr = jasmine . createSpy ( 'attr() spy' ) . and . returnValue ( 'radio' ) ;
204- element . is = jasmine . createSpy ( 'is() spy' ) . and . returnValue ( true ) ;
204+ var siblings = jasmine . createSpyObj ( 'siblings' , [ 'removeAttr' ] ) ;
205+ element . siblings = jasmine . createSpy ( 'siblings() spy' ) . and . returnValue ( siblings ) ;
205206
206207 fieldModel . resetValue ( ) ;
207208 expect ( element . removeAttr ) . toHaveBeenCalledWith ( "checked" ) ;
209+ expect ( element . siblings ) . toHaveBeenCalledWith ( 'input[type="radio"]' ) ;
210+ expect ( siblings . removeAttr ) . toHaveBeenCalledWith ( "checked" ) ;
211+ } )
212+
213+ it ( "should reset checked on all sibling radio buttons in a radio set with multiple options" , function ( ) {
214+ var fieldModel = new FieldModel ( ) ;
215+ var firstRadio = jasmine . createSpyObj ( 'firstRadio' , [ 'removeAttr' , 'removeClass' , 'show' , 'attr' , 'is' , 'find' , 'val' ] ) ;
216+ fieldModel . element = firstRadio ;
217+ firstRadio . find = jasmine . createSpy ( 'find() spy' ) . and . returnValue ( [ ] ) ;
218+ firstRadio . attr = jasmine . createSpy ( 'attr() spy' ) . and . returnValue ( 'radio' ) ;
219+ var otherRadios = jasmine . createSpyObj ( 'otherRadios' , [ 'removeAttr' ] ) ;
220+ firstRadio . siblings = jasmine . createSpy ( 'siblings() spy' ) . and . returnValue ( otherRadios ) ;
221+
222+ fieldModel . resetValue ( ) ;
223+ expect ( firstRadio . removeAttr ) . toHaveBeenCalledWith ( "checked" ) ;
224+ expect ( firstRadio . siblings ) . toHaveBeenCalledWith ( 'input[type="radio"]' ) ;
225+ expect ( otherRadios . removeAttr ) . toHaveBeenCalledWith ( "checked" ) ;
208226 } )
209227
210228 } ) ;
0 commit comments