- confugure vitest

- TreeButton.spec, Tree.spec update tests
pull/6170/head
uros 2024-08-01 10:40:12 +02:00
parent 706e623506
commit 71d6789db8
4 changed files with 24 additions and 13 deletions

View File

@ -0,0 +1,17 @@
import { config } from '@vue/test-utils';
import { defaultOptions } from 'primevue/config';
config.global.mocks['$primevue'] = {
config: defaultOptions
};
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addEventListener: vi.fn(),
removeEventListener: vi.fn()
}))
});

View File

@ -2,10 +2,8 @@ import vue from '@vitejs/plugin-vue';
import path from 'path';
import { mergeConfig } from 'vite';
import { defineConfig } from 'vitest/config';
import aliasConfig from './nuxt-vite.config.js';
export default mergeConfig(
aliasConfig,
defineConfig({
plugins: [vue()],
test: {
@ -18,12 +16,8 @@ export default mergeConfig(
provider: 'istanbul',
reporter: ['text', 'json', 'html']
},
setupFiles: [path.resolve(__dirname, './components/lib/config/PrimeVue.spec.js')]
},
resolve: {
alias: {
//'primevue/config': path.resolve(__dirname, './components/lib/config/PrimeVue.js')
}
setupFiles: [path.resolve(__dirname, './config.setup.js')],
include: [path.resolve(__dirname, '../../**/*.spec.js')]
}
})
);

View File

@ -16,7 +16,7 @@ describe('ToggleButton', () => {
it('is ToggleButton exist', () => {
expect(wrapper.find('.p-togglebutton.p-component').exists()).toBe(true);
expect(wrapper.find('span.pi-times.p-button-icon').exists()).toBe(true);
expect(wrapper.find('span.pi-times.p-togglebutton-icon').exists()).toBe(true);
});
it('should have onIcon', async () => {
@ -44,11 +44,11 @@ describe('ToggleButton', () => {
style: 'width: 10em'
});
expect(wrapper.find('.p-button-label').text()).toBe('I confirm');
expect(wrapper.find('.p-togglebutton-label').text()).toBe('I confirm');
expect(wrapper.attributes().style).toContain('width: 10em');
await wrapper.setProps({ modelValue: false });
expect(wrapper.find('.p-button-label').text()).toBe('I reject');
expect(wrapper.find('.p-togglebutton-label').text()).toBe('I reject');
});
});

View File

@ -48,7 +48,7 @@ describe('Tree.vue', () => {
}
});
let searchField = wrapper.find('input.p-tree-filter');
let searchField = wrapper.find('input.p-inputtext');
await searchField.trigger('keydown.space');
@ -57,7 +57,7 @@ describe('Tree.vue', () => {
it('should render icon', ({ expect }) => {
expect(wrapper.find('span.pi-inbox').exists()).toBeTruthy();
expect(wrapper.find('span.pi-inbox').classes('p-treenode-icon')).toBeTruthy();
expect(wrapper.find('span.pi-inbox').classes('p-tree-node-icon')).toBeTruthy();
});
it('should render icon slot', ({ expect }) => {