test(settings): refactor getWrapper function in settings input test

Updated the getWrapper function to use object destructuring.
This commit is contained in:
2026-07-28 20:10:24 +02:00
parent 67ffd05566
commit 2d61e9f927
@@ -20,7 +20,7 @@ import { useSettingsStore } from '../../stores/settingsStore.js';
import { describe, expect, test } from 'vitest';
import { nextTick } from 'vue';
const getWrapper = function getWrapper(type = 'string', i18n = 'input', piniaOptions = {}) {
const getWrapper = function getWrapper({ type = 'string', i18n = 'input', piniaOptions = {} } = {}) {
return mountComponent(SettingsInput, {
attrs: {
setting: {
@@ -40,7 +40,7 @@ describe('SettingsInput', () => {
const stringInputElement = stringSettingWrapper.find('input');
expect(stringInputElement.attributes('type')).toBe('text');
const numberSettingWrapper = getWrapper('number');
const numberSettingWrapper = getWrapper({ type: 'number' });
const numberInputElement = numberSettingWrapper.find('input');
expect(numberInputElement.attributes('type')).toBe('number');
@@ -55,10 +55,14 @@ describe('SettingsInput', () => {
test('shows value from store', () => {
const value = 'example value';
const stringSettingWrapper = getWrapper('string', 'input', {
setupStores: () => {
const store = useSettingsStore();
store.settings.input = value;
const stringSettingWrapper = getWrapper({
type: 'string',
i18n: 'input',
piniaOptions: {
setupStores: () => {
const store = useSettingsStore();
store.settings.input = value;
}
}
});
const inputElement = stringSettingWrapper.find('input');