Add global mocks for $primevue config on test

pull/3913/head
mertsincan 2023-04-28 14:58:46 +01:00
parent f6b5ca26ab
commit ed9af4cfb3
13 changed files with 19 additions and 134 deletions

View File

@ -1,16 +1,7 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { beforeEach, expect } from 'vitest'; import { beforeEach, expect } from 'vitest';
import BlockUI from './BlockUI.vue'; import BlockUI from './BlockUI.vue';
config.global.mocks = {
$primevue: {
config: {
zIndex: {
modal: 1100
}
}
}
};
vi.mock('primevue/utils'); vi.mock('primevue/utils');
let wrapper = null; let wrapper = null;

View File

@ -1,7 +1,7 @@
import { FilterMatchMode } from 'primevue/api'; import { FilterMatchMode } from 'primevue/api';
import { inject, reactive } from 'vue'; import { inject, reactive } from 'vue';
const defaultOptions = { export const defaultOptions = {
ripple: false, ripple: false,
inputStyle: 'outlined', inputStyle: 'outlined',
locale: { locale: {

View File

@ -0,0 +1,6 @@
import { config } from '@vue/test-utils';
import { defaultOptions } from 'primevue/config';
config.global.mocks['$primevue'] = {
config: defaultOptions
};

View File

@ -1,19 +1,6 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import DataViewLayoutOptions from './DataViewLayoutOptions.vue'; import DataViewLayoutOptions from './DataViewLayoutOptions.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
listView: 'listView',
gridView: 'gridView'
}
}
}
}
};
describe('DataViewLayoutOptions.vue', () => { describe('DataViewLayoutOptions.vue', () => {
it('should exist', async () => { it('should exist', async () => {
const wrapper = mount(DataViewLayoutOptions, { const wrapper = mount(DataViewLayoutOptions, {

View File

@ -1,19 +1,7 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import InputText from 'primevue/inputtext'; import InputText from 'primevue/inputtext';
import Inplace from './Inplace.vue'; import Inplace from './Inplace.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
close: 'Close'
}
}
}
}
};
describe('Inplace.vue', () => { describe('Inplace.vue', () => {
it('should exist', () => { it('should exist', () => {
const wrapper = mount(Inplace); const wrapper = mount(Inplace);

View File

@ -1,20 +1,6 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Listbox from './Listbox.vue'; import Listbox from './Listbox.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
trueLabel: 'trueLabel',
falseLabel: 'falseLabel',
nullLabel: 'nullLabel'
}
}
}
}
};
describe('Listbox.vue', () => { describe('Listbox.vue', () => {
let wrapper; let wrapper;

View File

@ -1,18 +1,6 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Menubar from './Menubar.vue'; import Menubar from './Menubar.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
navigation: 'Navigation'
}
}
}
}
};
describe('Menubar.vue', () => { describe('Menubar.vue', () => {
let wrapper; let wrapper;

View File

@ -1,19 +1,6 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import PrimeVue from 'primevue/config';
import Message from './Message.vue'; import Message from './Message.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
close: 'Close'
}
}
}
}
};
describe('Message.vue', () => { describe('Message.vue', () => {
let wrapper; let wrapper;

View File

@ -1,17 +1,6 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Password from './Password.vue'; import Password from './Password.vue';
config.global.mocks = {
$primevue: {
config: {
'z-index': 5,
inputStyle: 'filled',
ripple: false,
locale: {}
}
}
};
describe('Password.vue', () => { describe('Password.vue', () => {
let wrapper; let wrapper;
const event = { target: { value: 'P' } }; const event = { target: { value: 'P' } };

View File

@ -1,20 +1,6 @@
import { mount, config } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import PickList from './PickList.vue'; import PickList from './PickList.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
moveUp: 'Move Up',
moveDown: 'Move Down',
moveTop: 'Move Top',
moveBottom: 'Move Bottom'
}
}
}
}
};
describe('PickList.vue', () => { describe('PickList.vue', () => {
let wrapper; let wrapper;

View File

@ -1,18 +1,7 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { expect } from 'vitest'; import { expect } from 'vitest';
import Rating from './Rating.vue'; import Rating from './Rating.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
stars: '5'
}
}
}
}
};
describe('Rating.vue', () => { describe('Rating.vue', () => {
let wrapper; let wrapper;

View File

@ -1,19 +1,6 @@
import { config, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import TriStateCheckbox from './TriStateCheckbox.vue'; import TriStateCheckbox from './TriStateCheckbox.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
trueLabel: 'trueLabel',
falseLabel: 'falseLabel',
nullLabel: 'nullLabel'
}
}
}
}
};
let wrapper; let wrapper;
const modelValues = [true, false, null]; const modelValues = [true, false, null];
const emittedResults = [false, null, true]; const emittedResults = [false, null, true];

View File

@ -14,7 +14,8 @@ export default mergeConfig(
coverage: { coverage: {
provider: 'istanbul', provider: 'istanbul',
reporter: ['text', 'json', 'html'] reporter: ['text', 'json', 'html']
} },
setupFiles: [path.resolve(__dirname, './components/lib/config/PrimeVue.spec.js')]
}, },
resolve: { resolve: {
alias: { alias: {