mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
39 lines
953 B
JavaScript
39 lines
953 B
JavaScript
import agents from '../agents';
|
|
import ApiClient from '../ApiClient';
|
|
|
|
describe('#AgentAPI', () => {
|
|
it('creates correct instance', () => {
|
|
expect(agents).toBeInstanceOf(ApiClient);
|
|
expect(agents).toHaveProperty('get');
|
|
expect(agents).toHaveProperty('show');
|
|
expect(agents).toHaveProperty('create');
|
|
expect(agents).toHaveProperty('update');
|
|
expect(agents).toHaveProperty('delete');
|
|
});
|
|
|
|
describe('API calls', () => {
|
|
const originalAxios = window.axios;
|
|
const axiosMock = {
|
|
post: jest.fn(() => Promise.resolve()),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
window.axios = axiosMock;
|
|
});
|
|
|
|
afterEach(() => {
|
|
window.axios = originalAxios;
|
|
});
|
|
|
|
it('#bulkInvite', () => {
|
|
agents.bulkInvite({ emails: ['hello@hi.com'] });
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/api/v1/agents/bulk_create',
|
|
{
|
|
emails: ['hello@hi.com'],
|
|
}
|
|
);
|
|
});
|
|
});
|
|
});
|