diff --git a/apps/showcase/config.setup.js b/apps/showcase/config.setup.js new file mode 100644 index 000000000..54cb1d177 --- /dev/null +++ b/apps/showcase/config.setup.js @@ -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() + })) +}); diff --git a/apps/showcase/vitest.config.js b/apps/showcase/vitest.config.js index be1b5ef4d..6602f0560 100644 --- a/apps/showcase/vitest.config.js +++ b/apps/showcase/vitest.config.js @@ -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')] } }) ); diff --git a/packages/primevue/src/togglebutton/ToggleButton.spec.js b/packages/primevue/src/togglebutton/ToggleButton.spec.js index b21e4d490..3a8a1715f 100644 --- a/packages/primevue/src/togglebutton/ToggleButton.spec.js +++ b/packages/primevue/src/togglebutton/ToggleButton.spec.js @@ -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'); }); }); diff --git a/packages/primevue/src/tree/Tree.spec.js b/packages/primevue/src/tree/Tree.spec.js index a791a3ba3..3abc504cb 100644 --- a/packages/primevue/src/tree/Tree.spec.js +++ b/packages/primevue/src/tree/Tree.spec.js @@ -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 }) => {