UNPKG

n8n-nodes-highlevelv2

Version:

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

84 lines 3.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const GenericFunctions_1 = require("../GenericFunctions"); describe('addLocationIdPreSendAction', () => { let mockThis; beforeEach(() => { mockThis = { getNodeParameter: jest.fn(), getCredentials: jest.fn(), }; }); it('should add locationId to query parameters for contact getAll operation', async () => { mockThis.getNodeParameter .mockReturnValueOnce('contact') .mockReturnValueOnce('getAll'); mockThis.getCredentials.mockResolvedValue({ oauthTokenData: { locationId: '123' }, }); const requestOptions = { url: 'https://example.com/api', qs: {}, }; const result = await GenericFunctions_1.addLocationIdPreSendAction.call(mockThis, requestOptions); expect(result.qs).toEqual({ locationId: '123' }); }); it('should add locationId to the body for contact create operation', async () => { mockThis.getNodeParameter .mockReturnValueOnce('contact') .mockReturnValueOnce('create'); mockThis.getCredentials.mockResolvedValue({ oauthTokenData: { locationId: '123' }, }); const requestOptions = { url: 'https://example.com/api', body: {}, }; const result = await GenericFunctions_1.addLocationIdPreSendAction.call(mockThis, requestOptions); expect(result.body).toEqual({ locationId: '123' }); }); it('should add locationId to query parameters for opportunity getAll operation', async () => { mockThis.getNodeParameter .mockReturnValueOnce('opportunity') .mockReturnValueOnce('getAll'); mockThis.getCredentials.mockResolvedValue({ oauthTokenData: { locationId: '123' }, }); const requestOptions = { url: 'https://example.com/api', qs: {}, }; const result = await GenericFunctions_1.addLocationIdPreSendAction.call(mockThis, requestOptions); expect(result.qs).toEqual({ location_id: '123' }); }); it('should add locationId to the body for opportunity create operation', async () => { mockThis.getNodeParameter .mockReturnValueOnce('opportunity') .mockReturnValueOnce('create'); mockThis.getCredentials.mockResolvedValue({ oauthTokenData: { locationId: '123' }, }); const requestOptions = { url: 'https://example.com/api', body: {}, }; const result = await GenericFunctions_1.addLocationIdPreSendAction.call(mockThis, requestOptions); expect(result.body).toEqual({ locationId: '123' }); }); it('should not modify requestOptions if no resource or operation matches', async () => { mockThis.getNodeParameter .mockReturnValueOnce('unknown') .mockReturnValueOnce('unknown'); mockThis.getCredentials.mockResolvedValue({ oauthTokenData: { locationId: '123' }, }); const requestOptions = { url: 'https://example.com/api', body: {}, qs: {}, }; const result = await GenericFunctions_1.addLocationIdPreSendAction.call(mockThis, requestOptions); expect(result).toEqual(requestOptions); }); }); //# sourceMappingURL=AddLocationIdPreSendAction.test.js.map