generated from Seekra/repository-template
Feat(settings): add renderer for settings configuration #142
@@ -20,18 +20,22 @@ 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 ({ i18n = 'switch1', translations = {} } = {}) {
|
||||||
|
return mountComponent(Switch, {
|
||||||
|
attrs: {
|
||||||
|
jakob.scheid marked this conversation as resolved
Outdated
|
|||||||
|
setting: {
|
||||||
|
type: 'bool',
|
||||||
|
name: 'switch',
|
||||||
|
i18n
|
||||||
|
},
|
||||||
|
path: 'switch'
|
||||||
|
}
|
||||||
|
}, translations);
|
||||||
|
};
|
||||||
|
|
||||||
describe('Switch', () => {
|
describe('Switch', () => {
|
||||||
test('shows value from store', async () => {
|
test('shows value from store', async () => {
|
||||||
const wrapper = mountComponent(Switch, {
|
const wrapper = getWrapper();
|
||||||
attrs: {
|
|
||||||
setting: {
|
|
||||||
name: 'switch',
|
|
||||||
i18n: 'switch1',
|
|
||||||
type: 'bool'
|
|
||||||
},
|
|
||||||
path: 'switch'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const store = useSettingsStore();
|
const store = useSettingsStore();
|
||||||
store.set('switch', true);
|
store.set('switch', true);
|
||||||
@@ -50,16 +54,7 @@ describe('Switch', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('toggles value in store', async () => {
|
test('toggles value in store', async () => {
|
||||||
const wrapper = mountComponent(Switch, {
|
const wrapper = getWrapper();
|
||||||
attrs: {
|
|
||||||
setting: {
|
|
||||||
name: 'switch',
|
|
||||||
i18n: 'switch1',
|
|
||||||
type: 'bool'
|
|
||||||
},
|
|
||||||
path: 'switch'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const switchElement = wrapper.find('.switch-wrapper');
|
const switchElement = wrapper.find('.switch-wrapper');
|
||||||
|
|
||||||
@@ -78,18 +73,9 @@ describe('Switch', () => {
|
|||||||
test('shows correct translation', () => {
|
test('shows correct translation', () => {
|
||||||
const translation = 'Switch';
|
const translation = 'Switch';
|
||||||
|
|
||||||
const wrapper = mountComponent(Switch, {
|
const wrapper = getWrapper({
|
||||||
attrs: {
|
translations: { switch1: translation }
|
||||||
setting: {
|
})
|
||||||
name: 'switch',
|
|
||||||
i18n: 'switch1',
|
|
||||||
type: 'bool'
|
|
||||||
},
|
|
||||||
path: 'switch'
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
switch1: translation
|
|
||||||
});
|
|
||||||
|
|
||||||
const label = wrapper.find('label');
|
const label = wrapper.find('label');
|
||||||
expect(label.text()).toBe(translation);
|
expect(label.text()).toBe(translation);
|
||||||
|
|||||||
Reference in New Issue
Block a user
Please add a function to get the wrapper and avoid repeating code.