@@ -192,6 +192,58 @@ describe('Rendering', () => {
192
192
`Pickup - ${ JSON . stringify ( { checked : false , active : false } ) } `
193
193
)
194
194
} )
195
+
196
+ it ( 'should set the checked v-slot info to true for the selected item (testing with objects, because Vue proxies)' , async ( ) => {
197
+ renderTemplate ( {
198
+ template : html `
199
+ < RadioGroup v-model ="deliveryMethod ">
200
+ < RadioGroupLabel > Pizza Delivery</ RadioGroupLabel >
201
+ < RadioGroupOption v-for ="option in options " key ="option.id " :value ="option " v-slot ="data "
202
+ > {{option.label}} - {{JSON.stringify(data)}}</ RadioGroupOption
203
+ >
204
+ </ RadioGroup >
205
+ ` ,
206
+ setup ( ) {
207
+ let deliveryMethod = ref ( undefined )
208
+ let options = ref ( [
209
+ { id : 1 , label : 'Pickup' } ,
210
+ { id : 2 , label : 'Home delivery' } ,
211
+ { id : 3 , label : 'Dine in' } ,
212
+ ] )
213
+ return { deliveryMethod, options }
214
+ } ,
215
+ } )
216
+
217
+ await new Promise < void > ( nextTick )
218
+
219
+ let [ pickup , homeDelivery , dineIn ] = Array . from (
220
+ document . querySelectorAll ( '[id^="headlessui-radiogroup-option-"]' )
221
+ )
222
+ expect ( pickup ) . toHaveTextContent (
223
+ `Pickup - ${ JSON . stringify ( { checked : false , active : false } ) } `
224
+ )
225
+ expect ( homeDelivery ) . toHaveTextContent (
226
+ `Home delivery - ${ JSON . stringify ( { checked : false , active : false } ) } `
227
+ )
228
+ expect ( dineIn ) . toHaveTextContent (
229
+ `Dine in - ${ JSON . stringify ( { checked : false , active : false } ) } `
230
+ )
231
+
232
+ await click ( homeDelivery )
233
+ ; [ pickup , homeDelivery , dineIn ] = Array . from (
234
+ document . querySelectorAll ( '[id^="headlessui-radiogroup-option-"]' )
235
+ )
236
+
237
+ expect ( pickup ) . toHaveTextContent (
238
+ `Pickup - ${ JSON . stringify ( { checked : false , active : false } ) } `
239
+ )
240
+ expect ( homeDelivery ) . toHaveTextContent (
241
+ `Home delivery - ${ JSON . stringify ( { checked : true , active : true } ) } `
242
+ )
243
+ expect ( dineIn ) . toHaveTextContent (
244
+ `Dine in - ${ JSON . stringify ( { checked : false , active : false } ) } `
245
+ )
246
+ } )
195
247
} )
196
248
197
249
describe ( 'Keyboard interactions' , ( ) => {
0 commit comments