import customRole from '../customRole'; describe('#CustomRoleAPI', () => { const originalAxios = window.axios; const axiosMock = { post: vi.fn(() => Promise.resolve()), patch: vi.fn(() => Promise.resolve()), }; beforeEach(() => { window.axios = axiosMock; }); afterEach(() => { window.axios = originalAxios; vi.clearAllMocks(); }); it('wraps create and update payloads for the backend contract', () => { const payload = { name: 'Support', description: 'Support role', permissions: ['contact_manage'], }; customRole.create(payload); customRole.update(7, payload); expect(axiosMock.post).toHaveBeenCalledWith('/api/v1/custom_roles', { custom_role: payload, }); expect(axiosMock.patch).toHaveBeenCalledWith('/api/v1/custom_roles/7', { custom_role: payload, }); }); });