import { DashboardController } from '@/core'; import { useEventBind, useNavParamsBind } from "@/hooks/use-ctrl"; import { model } from './dashboard-controller-model'; const evt = useEventBind(emit); const params: any = { name: model.name, model, evt, closeView: undefined, pLoadingHelper: undefined, pViewCtx: undefined, actions: undefined, handler: undefined }; const context = { }; const viewParams = { }; const controller: any = new DashboardController(params); useNavParamsBind(controller, { context, viewParams }); const getPortletCtrlAbility = () => { return { load: async () => { return { ok: true, data: null, rowData: { status: 200 } } } } } const getPortletCtrlAbilitySpy = vi.spyOn(controller, 'getPortletCtrlAbility').mockImplementation(getPortletCtrlAbility); describe('DashboardController unit test', () => { test('load', async () => { await expect(controller.load()).resolves.toHaveProperty('ok', true); expect(getPortletCtrlAbilitySpy).toHaveBeenCalledTimes(model.portletArray.length); }) })