This commit is contained in:
parent
14ac4f7de6
commit
1ba24b46db
|
@ -108,7 +108,7 @@ vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||||
path: 'mockName/1',
|
path: 'mockName/1',
|
||||||
name: 'Customer',
|
name: 'Customer',
|
||||||
});
|
});
|
||||||
function mount(source) {
|
function mount(source = 'main') {
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||||
data: [],
|
data: [],
|
||||||
});
|
});
|
||||||
|
@ -186,7 +186,7 @@ describe('Leftmenu as card', () => {
|
||||||
});
|
});
|
||||||
describe('Leftmenu as main', () => {
|
describe('Leftmenu as main', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vm = mount('main').vm;
|
vm = mount().vm;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should initialize with default props', () => {
|
it('should initialize with default props', () => {
|
||||||
|
@ -324,6 +324,39 @@ describe('normalize', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('addChildren', () => {
|
describe('addChildren', () => {
|
||||||
|
const module = 'testModule';
|
||||||
|
beforeEach(() => {
|
||||||
|
vm = mount().vm;
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add menu items to parent if matches are found', () => {
|
||||||
|
const parent = 'testParent';
|
||||||
|
const route = {
|
||||||
|
meta: {
|
||||||
|
menu: 'testMenu',
|
||||||
|
},
|
||||||
|
children: [{ name: 'child1' }, { name: 'child2' }],
|
||||||
|
};
|
||||||
|
vm.addChildren(module, route, parent);
|
||||||
|
|
||||||
|
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle routes with no meta menu', () => {
|
||||||
|
const route = {
|
||||||
|
meta: {},
|
||||||
|
menus: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const parent = [];
|
||||||
|
|
||||||
|
vm.addChildren(module, route, parent);
|
||||||
|
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle empty parent array', () => {
|
||||||
|
const parent = [];
|
||||||
const route = {
|
const route = {
|
||||||
meta: {
|
meta: {
|
||||||
menu: 'child11',
|
menu: 'child11',
|
||||||
|
@ -343,32 +376,6 @@ describe('addChildren', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
beforeEach(() => {
|
|
||||||
vm = mount('main').vm;
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add menu items to parent if matches are found', () => {
|
|
||||||
const module = 'testModule';
|
|
||||||
const parent = [];
|
|
||||||
|
|
||||||
vm.addChildren(module, route, parent);
|
|
||||||
|
|
||||||
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle routes with no meta menu', () => {
|
|
||||||
const module = 'testModule';
|
|
||||||
const parent = [];
|
|
||||||
|
|
||||||
vm.addChildren(module, route, parent);
|
|
||||||
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle empty parent array', () => {
|
|
||||||
const module = 'testModule';
|
|
||||||
const parent = [];
|
|
||||||
|
|
||||||
vm.addChildren(module, route, parent);
|
vm.addChildren(module, route, parent);
|
||||||
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue