UNPKG

n8n-nodes-highlevelv2

Version:

n8n community node for HighLevel v2 API integration - comprehensive CRM, marketing automation, and business management platform

37 lines 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const GenericFunctions_1 = require("../GenericFunctions"); describe('getContacts', () => { const mockHighLevelApiRequest = jest.fn(); const mockGetCredentials = jest.fn(); const mockContext = { getCredentials: mockGetCredentials, helpers: { httpRequestWithAuthentication: mockHighLevelApiRequest, }, }; beforeEach(() => { mockHighLevelApiRequest.mockClear(); mockGetCredentials.mockClear(); }); it('should return a list of contacts', async () => { const mockContacts = [ { id: '1', name: 'Alice', email: 'alice@example.com' }, { id: '2', name: 'Bob', email: 'bob@example.com' }, ]; mockHighLevelApiRequest.mockResolvedValue({ contacts: mockContacts }); mockGetCredentials.mockResolvedValue({ oauthTokenData: { locationId: '123' } }); const response = await GenericFunctions_1.getContacts.call(mockContext); expect(response).toEqual([ { name: 'alice@example.com', value: '1' }, { name: 'bob@example.com', value: '2' }, ]); }); it('should handle empty contacts list', async () => { mockHighLevelApiRequest.mockResolvedValue({ contacts: [] }); mockGetCredentials.mockResolvedValue({ oauthTokenData: { locationId: '123' } }); const response = await GenericFunctions_1.getContacts.call(mockContext); expect(response).toEqual([]); }); }); //# sourceMappingURL=GetContacts.test.js.map