feat: complete current GoChat updates
This commit is contained in:
@@ -4,6 +4,14 @@ class CustomRole extends ApiClient {
|
||||
constructor() {
|
||||
super('custom_roles', { accountScoped: true });
|
||||
}
|
||||
|
||||
create(data) {
|
||||
return super.create({ custom_role: data });
|
||||
}
|
||||
|
||||
update(id, data) {
|
||||
return super.update(id, { custom_role: data });
|
||||
}
|
||||
}
|
||||
|
||||
export default new CustomRole();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
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,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user