generated from Seekra/repository-template
Feat(settings): add renderer for settings configuration #142
@@ -20,20 +20,27 @@ import { useSettingsStore } from '../../stores/settingsStore.js';
|
|||||||
import { expect, describe, test } from 'vitest';
|
import { expect, describe, test } from 'vitest';
|
||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
|
|
||||||
const getWrapper = function getWrapper (options = {}) {
|
const getWrapper = function getWrapper ({
|
||||||
|
jakob.scheid marked this conversation as resolved
Outdated
|
|||||||
|
i18n = 'selection',
|
||||||
|
options = [],
|
||||||
|
allowMultiple = false,
|
||||||
|
defaultValue = undefined,
|
||||||
|
translations = {},
|
||||||
|
piniaOptions = {}
|
||||||
|
} = {}) {
|
||||||
return mountComponent(Selection, {
|
return mountComponent(Selection, {
|
||||||
attrs: {
|
attrs: {
|
||||||
setting: {
|
setting: {
|
||||||
name: 'selection',
|
name: 'selection',
|
||||||
type: 'selection',
|
type: 'selection',
|
||||||
i18n: options.i18n ?? 'selection',
|
i18n,
|
||||||
options: options.options ?? [],
|
options,
|
||||||
allowMultiple: options.allowMultiple ?? false,
|
allowMultiple,
|
||||||
default: options.default ?? null
|
default: defaultValue
|
||||||
},
|
},
|
||||||
path: 'selection'
|
path: 'selection'
|
||||||
}
|
}
|
||||||
}, options.translations ?? {}, [], options.piniaOptions ?? {});
|
}, translations, [], piniaOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getChecked = function getChecked (inputs) {
|
const getChecked = function getChecked (inputs) {
|
||||||
@@ -108,7 +115,7 @@ describe('Selection', () => {
|
|||||||
test('shows default value', () => {
|
test('shows default value', () => {
|
||||||
const wrapper = getWrapper({
|
const wrapper = getWrapper({
|
||||||
options: exampleOptions,
|
options: exampleOptions,
|
||||||
default: 'o2'
|
defaultValue: 'o2'
|
||||||
});
|
});
|
||||||
|
|
||||||
const inputs = wrapper.findAll('input');
|
const inputs = wrapper.findAll('input');
|
||||||
@@ -119,7 +126,7 @@ describe('Selection', () => {
|
|||||||
test('shows multiple default values', () => {
|
test('shows multiple default values', () => {
|
||||||
const wrapper = getWrapper({
|
const wrapper = getWrapper({
|
||||||
options: exampleOptions,
|
options: exampleOptions,
|
||||||
default: ['o0', 'o1'],
|
defaultValue: ['o0', 'o1'],
|
||||||
allowMultiple: true
|
allowMultiple: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user
I think object destructuring would make more sense here.