generated from Seekra/repository-template
Compare commits
10
Commits
main
..
646cc13751
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
646cc13751
|
||
|
|
dfac9f7da3
|
||
|
|
dd8263b2b8
|
||
|
|
589d886a63
|
||
|
|
a14189e130
|
||
|
|
d0a2cce293
|
||
|
|
15b2673643
|
||
|
|
e62fdea1b4
|
||
|
|
542d295650
|
||
|
|
8177d67ed1
|
@@ -54,9 +54,10 @@ const props = defineProps({
|
|||||||
const store = useSettingsStore();
|
const store = useSettingsStore();
|
||||||
|
|
||||||
const optionType = computed(() => props.setting.allowMultiple ? 'checkbox' : 'radio');
|
const optionType = computed(() => props.setting.allowMultiple ? 'checkbox' : 'radio');
|
||||||
const selected = computed({
|
const selected = ref(normalizeSelectedValue(store.get(props.path) ?? props.setting.default));
|
||||||
get: () => normalizeSelectedValue(store.get(props.path) ?? props.setting.default),
|
|
||||||
set: (value) => store.set(props.path, value)
|
watch(selected, (newValue) => {
|
||||||
|
store.set(props.path, newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
const labelId = useId();
|
const labelId = useId();
|
||||||
|
|||||||
@@ -90,32 +90,6 @@ describe('Selection', () => {
|
|||||||
expect(inputsChecked).toStrictEqual([false, true, false]);
|
expect(inputsChecked).toStrictEqual([false, true, false]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reacts on store change', async () => {
|
|
||||||
const wrapper = getWrapper({
|
|
||||||
options: exampleOptions,
|
|
||||||
piniaOptions: {
|
|
||||||
setupStores: () => {
|
|
||||||
const store = useSettingsStore();
|
|
||||||
store.set('selection', 'o1');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const settings = useSettingsStore();
|
|
||||||
|
|
||||||
{
|
|
||||||
const inputs = wrapper.findAll('input');
|
|
||||||
const inputsChecked = getChecked(inputs);
|
|
||||||
expect(inputsChecked).toStrictEqual([false, true, false]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
settings.set('selection', 'o2');
|
|
||||||
await nextTick();
|
|
||||||
const inputs = wrapper.findAll('input');
|
|
||||||
const inputsChecked = getChecked(inputs);
|
|
||||||
expect(inputsChecked).toStrictEqual([false, false, true]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('shows multiple values from store', () => {
|
test('shows multiple values from store', () => {
|
||||||
const wrapper = getWrapper({
|
const wrapper = getWrapper({
|
||||||
options: exampleOptions,
|
options: exampleOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user