Skip to content

Commit

Permalink
refact: move const contact to general use
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuseduardomedeiros committed Dec 11, 2024
1 parent 46fa532 commit 72b7ef8
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ vi.mock('@/utils/config', () => ({
describe('Link Contact Service', () => {
const uuid = getProject();

const contact = { id: 'contact-id' };

describe('getLinketContact', () => {
it('should make a GET request to /project/{uuid}/retrieve_linked_contact/ with correct params', async () => {
const mockResponse = { data: { linkedContact: true } };
http.get.mockResolvedValue(mockResponse);

const contact = { id: 'contact-id' };

const result = await linkContact.getLinketContact(contact);

expect(http.get).toHaveBeenCalledWith(
Expand All @@ -35,8 +35,6 @@ describe('Link Contact Service', () => {
const mockResponse = { data: { success: true } };
http.post.mockResolvedValue(mockResponse);

const contact = { id: 'contact-id' };

const result = await linkContact.linkContactToAgent(contact);

expect(http.post).toHaveBeenCalledWith(
Expand All @@ -52,8 +50,6 @@ describe('Link Contact Service', () => {
const mockResponse = { data: { success: true } };
http.delete.mockResolvedValue(mockResponse);

const contact = { id: 'contact-id' };

const result = await linkContact.removeContactFromAgent(contact);

expect(http.delete).toHaveBeenCalledWith(
Expand All @@ -70,8 +66,6 @@ describe('Link Contact Service', () => {
const mockError = { response: { status: 404, data: 'Not Found' } };
http.get.mockRejectedValue(mockError);

const contact = { id: 'contact-id' };

linkContact.getLinketContact(contact).catch((err) => {
expect(err.response).toEqual(mockError.response);
});
Expand All @@ -81,8 +75,6 @@ describe('Link Contact Service', () => {
const mockError = { response: { status: 400, data: 'Bad Request' } };
http.post.mockRejectedValue(mockError);

const contact = { id: 'contact-id' };

linkContact.linkContactToAgent(contact).catch((err) => {
expect(err.response).toEqual(mockError.response);
});
Expand All @@ -92,8 +84,6 @@ describe('Link Contact Service', () => {
const mockError = { response: { status: 500, data: 'Server Error' } };
http.delete.mockRejectedValue(mockError);

const contact = { id: 'contact-id' };

linkContact.removeContactFromAgent(contact).catch((err) => {
expect(err.response).toEqual(mockError.response);
});
Expand Down

0 comments on commit 72b7ef8

Please sign in to comment.