|
@@ -449,77 +449,6 @@ test('can bind objects to the value',
|
|
|
},
|
|
|
)
|
|
|
|
|
|
-// @todo: fix this test
|
|
|
-test('can use "by" to specify which key to use for option comparison',
|
|
|
- [html`
|
|
|
- <main
|
|
|
- x-data="{
|
|
|
- active: null,
|
|
|
- access: [
|
|
|
- { id: 1 },
|
|
|
- { id: 2 },
|
|
|
- ]
|
|
|
- }"
|
|
|
- >
|
|
|
- <div x-radio group x-model="active" by="name">
|
|
|
- <template x-for="(option, i) in access" :key="option.id">
|
|
|
- <div
|
|
|
- :option="i"
|
|
|
- x-radio:option
|
|
|
- :value="{ id: i, 'name': 'value' }"
|
|
|
- >
|
|
|
- <span x-radio:label x-text="option.id"></span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
-
|
|
|
- <article x-text="JSON.stringify(active)"></article>
|
|
|
- </main>
|
|
|
- `],
|
|
|
- ({ get }) => {
|
|
|
- get('[option="1"]').click()
|
|
|
- get('article')
|
|
|
- .should(haveText(JSON.stringify({ id: i, 'name': 'value' })))
|
|
|
- },
|
|
|
-)
|
|
|
-
|
|
|
-// @todo: fix this test
|
|
|
-test('can use "by" to specify a comparison function',
|
|
|
- [html`
|
|
|
- <main
|
|
|
- x-data="{
|
|
|
- active: null,
|
|
|
- access: [
|
|
|
- { id: 1, },
|
|
|
- { id: 2, },
|
|
|
- ],
|
|
|
- compare(a, b) {
|
|
|
- return a.id === b.id
|
|
|
- }
|
|
|
- }
|
|
|
- ">
|
|
|
- <div x-radio group x-model="active" :by="compare">
|
|
|
- <template x-for="(option, i) in access" :key="option.id">
|
|
|
- <div
|
|
|
- :option="i"
|
|
|
- x-radio:option
|
|
|
- :value="{ id: i, 'name': 'value' }"
|
|
|
- >
|
|
|
- <span x-radio:label x-text="option.id"></span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
-
|
|
|
- <article x-text="JSON.stringify(active)"></article>
|
|
|
- </main>
|
|
|
- `],
|
|
|
- ({ get }) => {
|
|
|
- get('[option="1"]').click()
|
|
|
- get('article')
|
|
|
- .should(haveText(JSON.stringify({ id: i, 'name': 'value' })))
|
|
|
- },
|
|
|
-)
|
|
|
-
|
|
|
test('name prop',
|
|
|
[html`
|
|
|
<main
|