This commit is contained in:
parent
14ac4f7de6
commit
1ba24b46db
|
@ -108,7 +108,7 @@ vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
|||
path: 'mockName/1',
|
||||
name: 'Customer',
|
||||
});
|
||||
function mount(source) {
|
||||
function mount(source = 'main') {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||
data: [],
|
||||
});
|
||||
|
@ -186,7 +186,7 @@ describe('Leftmenu as card', () => {
|
|||
});
|
||||
describe('Leftmenu as main', () => {
|
||||
beforeEach(() => {
|
||||
vm = mount('main').vm;
|
||||
vm = mount().vm;
|
||||
});
|
||||
|
||||
it('should initialize with default props', () => {
|
||||
|
@ -324,41 +324,31 @@ describe('normalize', () => {
|
|||
});
|
||||
|
||||
describe('addChildren', () => {
|
||||
const route = {
|
||||
meta: {
|
||||
menu: 'child11',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'child1',
|
||||
meta: {
|
||||
menuChildren: [
|
||||
{
|
||||
name: 'CustomerCreditContracts',
|
||||
title: 'creditContracts',
|
||||
icon: 'vn:solunion',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
const module = 'testModule';
|
||||
beforeEach(() => {
|
||||
vm = mount('main').vm;
|
||||
vm = mount().vm;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should add menu items to parent if matches are found', () => {
|
||||
const module = 'testModule';
|
||||
const parent = [];
|
||||
|
||||
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 module = 'testModule';
|
||||
const route = {
|
||||
meta: {},
|
||||
menus: {},
|
||||
};
|
||||
|
||||
const parent = [];
|
||||
|
||||
vm.addChildren(module, route, parent);
|
||||
|
@ -366,9 +356,26 @@ describe('addChildren', () => {
|
|||
});
|
||||
|
||||
it('should handle empty parent array', () => {
|
||||
const module = 'testModule';
|
||||
const parent = [];
|
||||
|
||||
const route = {
|
||||
meta: {
|
||||
menu: 'child11',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'child1',
|
||||
meta: {
|
||||
menuChildren: [
|
||||
{
|
||||
name: 'CustomerCreditContracts',
|
||||
title: 'creditContracts',
|
||||
icon: 'vn:solunion',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
vm.addChildren(module, route, parent);
|
||||
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue