test: refs #7058 getRoutes
This commit is contained in:
parent
e5940ff785
commit
42f113ccf6
|
@ -132,6 +132,48 @@ function mount(source) {
|
|||
return wrapper;
|
||||
}
|
||||
|
||||
describe('getRoutes', () => {
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
const getRoutes = vi.fn().mockImplementation((props, getMethodA, getMethodB) => {
|
||||
const handleRoutes = {
|
||||
methodA: getMethodA,
|
||||
methodB: getMethodB,
|
||||
};
|
||||
try {
|
||||
handleRoutes[props.source]();
|
||||
} catch (error) {
|
||||
throw Error('Method not defined');
|
||||
}
|
||||
});
|
||||
|
||||
const getMethodA = vi.fn();
|
||||
const getMethodB = vi.fn();
|
||||
const fn = (props) => getRoutes(props, getMethodA, getMethodB);
|
||||
|
||||
it('should call getMethodB when source is card', () => {
|
||||
let props = { source: 'methodB' };
|
||||
fn(props);
|
||||
|
||||
expect(getMethodB).toHaveBeenCalled();
|
||||
expect(getMethodA).not.toHaveBeenCalled();
|
||||
});
|
||||
it('should call getMethodA when source is main', () => {
|
||||
let props = { source: 'methodA' };
|
||||
fn(props);
|
||||
|
||||
expect(getMethodA).toHaveBeenCalled();
|
||||
expect(getMethodB).not.toHaveBeenCalled();
|
||||
});
|
||||
//WIP
|
||||
it('should call getMethodA when source is main', () => {
|
||||
let props = { source: 'methodC' };
|
||||
expect(fn(props)).toThrowError('Method not defined');
|
||||
|
||||
expect(getMethodA).not.toHaveBeenCalled();
|
||||
expect(getMethodB).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Leftmenu as card', () => {
|
||||
beforeAll(() => {
|
||||
vm = mount('card').vm;
|
||||
|
@ -335,7 +377,7 @@ describe.only('addChildren', () => {
|
|||
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.only('should not add menu items if no matches are found', () => {
|
||||
it('should not add menu items if no matches are found', () => {
|
||||
const module = 'testModule';
|
||||
const route = {
|
||||
meta: { menu: 'child3', menuChildren: [] },
|
||||
|
|
Loading…
Reference in New Issue