generated from Seekra/repository-template
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53bd67b7a0
|
||
|
|
1f51a0b3ae
|
@@ -54,10 +54,9 @@ const props = defineProps({
|
||||
const store = useSettingsStore();
|
||||
|
||||
const optionType = computed(() => props.setting.allowMultiple ? 'checkbox' : 'radio');
|
||||
const selected = ref(normalizeSelectedValue(store.get(props.path) ?? props.setting.default));
|
||||
|
||||
watch(selected, (newValue) => {
|
||||
store.set(props.path, newValue);
|
||||
const selected = computed({
|
||||
get: () => normalizeSelectedValue(store.get(props.path) ?? props.setting.default),
|
||||
set: (value) => store.set(props.path, value)
|
||||
});
|
||||
|
||||
const labelId = useId();
|
||||
|
||||
@@ -90,6 +90,32 @@ describe('Selection', () => {
|
||||
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', () => {
|
||||
const wrapper = getWrapper({
|
||||
options: exampleOptions,
|
||||
|
||||
Reference in New Issue
Block a user