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 BlockUI from './BlockUI.vue';
config.global.mocks = {
$primevue: {
config: {
zIndex: {
modal: 1100
}
}
}
};
vi.mock('primevue/utils');
let wrapper = null;

View File

@ -1,7 +1,7 @@
import { FilterMatchMode } from 'primevue/api';
import { inject, reactive } from 'vue';
const defaultOptions = {
export const defaultOptions = {
ripple: false,
inputStyle: 'outlined',
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';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
listView: 'listView',
gridView: 'gridView'
}
}
}
}
};
describe('DataViewLayoutOptions.vue', () => {
it('should exist', async () => {
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 Inplace from './Inplace.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
close: 'Close'
}
}
}
}
};
describe('Inplace.vue', () => {
it('should exist', () => {
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';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
trueLabel: 'trueLabel',
falseLabel: 'falseLabel',
nullLabel: 'nullLabel'
}
}
}
}
};
describe('Listbox.vue', () => {
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';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
navigation: 'Navigation'
}
}
}
}
};
describe('Menubar.vue', () => {
let wrapper;

View File

@ -1,19 +1,6 @@
import { config, mount } from '@vue/test-utils';
import PrimeVue from 'primevue/config';
import { mount } from '@vue/test-utils';
import Message from './Message.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
close: 'Close'
}
}
}
}
};
describe('Message.vue', () => {
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';
config.global.mocks = {
$primevue: {
config: {
'z-index': 5,
inputStyle: 'filled',
ripple: false,
locale: {}
}
}
};
describe('Password.vue', () => {
let wrapper;
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';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
moveUp: 'Move Up',
moveDown: 'Move Down',
moveTop: 'Move Top',
moveBottom: 'Move Bottom'
}
}
}
}
};
describe('PickList.vue', () => {
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 Rating from './Rating.vue';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
stars: '5'
}
}
}
}
};
describe('Rating.vue', () => {
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';
config.global.mocks = {
$primevue: {
config: {
locale: {
aria: {
trueLabel: 'trueLabel',
falseLabel: 'falseLabel',
nullLabel: 'nullLabel'
}
}
}
}
};
let wrapper;
const modelValues = [true, false, null];
const emittedResults = [false, null, true];

View File

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