mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 04:27:53 +00:00
## Description Add account delete option in the user account settings. Fixes #1555 ## Type of change - [ ] New feature (non-breaking change which adds functionality)   ## Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Sojan Jose <sojan@pepalo.com> Co-authored-by: Sojan Jose <sojan.official@gmail.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
import accountAPI from '../account';
|
|
import ApiClient from '../../ApiClient';
|
|
|
|
describe('#enterpriseAccountAPI', () => {
|
|
it('creates correct instance', () => {
|
|
expect(accountAPI).toBeInstanceOf(ApiClient);
|
|
expect(accountAPI).toHaveProperty('get');
|
|
expect(accountAPI).toHaveProperty('show');
|
|
expect(accountAPI).toHaveProperty('create');
|
|
expect(accountAPI).toHaveProperty('update');
|
|
expect(accountAPI).toHaveProperty('delete');
|
|
expect(accountAPI).toHaveProperty('checkout');
|
|
expect(accountAPI).toHaveProperty('toggleDeletion');
|
|
});
|
|
|
|
describe('API calls', () => {
|
|
const originalAxios = window.axios;
|
|
const axiosMock = {
|
|
post: vi.fn(() => Promise.resolve()),
|
|
get: vi.fn(() => Promise.resolve()),
|
|
patch: vi.fn(() => Promise.resolve()),
|
|
delete: vi.fn(() => Promise.resolve()),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
window.axios = axiosMock;
|
|
});
|
|
|
|
afterEach(() => {
|
|
window.axios = originalAxios;
|
|
});
|
|
|
|
it('#checkout', () => {
|
|
accountAPI.checkout();
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/checkout'
|
|
);
|
|
});
|
|
|
|
it('#subscription', () => {
|
|
accountAPI.subscription();
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/subscription'
|
|
);
|
|
});
|
|
|
|
it('#toggleDeletion with delete action', () => {
|
|
accountAPI.toggleDeletion('delete');
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/toggle_deletion',
|
|
{ action_type: 'delete' }
|
|
);
|
|
});
|
|
|
|
it('#toggleDeletion with undelete action', () => {
|
|
accountAPI.toggleDeletion('undelete');
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/enterprise/api/v1/toggle_deletion',
|
|
{ action_type: 'undelete' }
|
|
);
|
|
});
|
|
});
|
|
});
|