#7058 LeftMenu vitest #1153
|
@ -0,0 +1,55 @@
|
||||||
|
import { describe, expect, it, beforeAll, beforeEach, vi } from 'vitest';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
|
import LeftMenu from 'src/components/LeftMenu.vue';
|
||||||
|
|
||||||
|
describe('LeftMenu', () => {
|
||||||
|
let wrapper;
|
||||||
|
let vm;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
wrapper = createWrapper(LeftMenu, {
|
||||||
|
propsData: {
|
||||||
|
source: 'main',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
vm = wrapper.vm;
|
||||||
|
|
||||||
|
vi.mock('src/composables/useNavigationStore', () => {
|
||||||
|
return {
|
||||||
|
useNavigationStore: vi.fn(() => ({
|
||||||
|
items: [],
|
||||||
|
expansionItemElements: {},
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
vm.search = null;
|
||||||
|
vm.items = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should initialize with default props', () => {
|
||||||
|
expect(vm.source).toBe('main');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should filter items based on search input', async () => {
|
||||||
|
vm.items = [
|
||||||
|
{ name: 'Item 1', isPinned: false },
|
||||||
|
{ name: 'Item 2', isPinned: true },
|
||||||
|
];
|
||||||
|
vm.search = 'Item 1';
|
||||||
|
await vm.$nextTick();
|
||||||
|
expect(vm.filteredItems).toEqual([{ name: 'Item 1', isPinned: false }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return pinned items', () => {
|
||||||
|
vm.items = [
|
||||||
|
{ name: 'Item 1', isPinned: false },
|
||||||
|
{ name: 'Item 2', isPinned: true },
|
||||||
|
];
|
||||||
|
expect(vm.pinnedModules).toEqual(
|
||||||
|
new Map([['Item 2', { name: 'Item 2', isPinned: true }]])
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue