UNPKG

n8n-nodes-highlevelv2

Version:

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

79 lines 3.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const GenericFunctions_1 = require("../GenericFunctions"); describe('addCustomFieldsPreSendAction', () => { let mockThis; beforeEach(() => { mockThis = { helpers: { httpRequest: jest.fn(), httpRequestWithAuthentication: jest.fn(), requestWithAuthenticationPaginated: jest.fn(), request: jest.fn(), requestWithAuthentication: jest.fn(), requestOAuth1: jest.fn(), requestOAuth2: jest.fn(), assertBinaryData: jest.fn(), getBinaryDataBuffer: jest.fn(), prepareBinaryData: jest.fn(), setBinaryDataBuffer: jest.fn(), copyBinaryFile: jest.fn(), binaryToBuffer: jest.fn(), binaryToString: jest.fn(), getBinaryPath: jest.fn(), getBinaryStream: jest.fn(), getBinaryMetadata: jest.fn(), createDeferredPromise: jest .fn() .mockReturnValue({ promise: Promise.resolve(), resolve: jest.fn(), reject: jest.fn() }), }, }; }); it('should format custom fields correctly when provided', async () => { const mockRequestOptions = { body: { customFields: { values: [ { fieldId: { value: '123', cachedResultName: 'FieldName' }, fieldValue: 'TestValue', }, { fieldId: { value: '456' }, fieldValue: 'AnotherValue', }, ], }, }, url: '', }; const result = await GenericFunctions_1.addCustomFieldsPreSendAction.call(mockThis, mockRequestOptions); expect(result.body.customFields).toEqual([ { id: '123', key: 'FieldName', field_value: 'TestValue' }, { id: '456', key: 'default_key', field_value: 'AnotherValue' }, ]); }); it('should not modify request body if customFields is not provided', async () => { const mockRequestOptions = { body: { otherField: 'SomeValue', }, url: '', }; const result = await GenericFunctions_1.addCustomFieldsPreSendAction.call(mockThis, mockRequestOptions); expect(result).toEqual(mockRequestOptions); }); it('should handle customFields with empty values', async () => { const mockRequestOptions = { body: { customFields: { values: [], }, }, url: '', }; const result = await GenericFunctions_1.addCustomFieldsPreSendAction.call(mockThis, mockRequestOptions); expect(result.body.customFields).toEqual([]); }); }); //# sourceMappingURL=AddCustomFieldsPreSendAction.test.js.map