UNPKG

n8n-nodes-highlevelv2

Version:

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

58 lines 2.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const GenericFunctions_1 = require("../GenericFunctions"); describe('taskPostReceiceAction', () => { let mockThis; beforeEach(() => { mockThis = { getNodeParameter: jest.fn((parameterName) => { if (parameterName === 'contactId') return '12345'; return undefined; }), }; }); it('should add contactId to each item in items', async () => { const items = [ { json: { field1: 'value1' } }, { json: { field2: 'value2' } }, ]; const response = { body: {}, headers: {}, statusCode: 200, }; const result = await GenericFunctions_1.taskPostReceiceAction.call(mockThis, items, response); expect(result).toEqual([ { json: { field1: 'value1', contactId: '12345' } }, { json: { field2: 'value2', contactId: '12345' } }, ]); expect(mockThis.getNodeParameter).toHaveBeenCalledWith('contactId'); }); it('should not modify other fields in items', async () => { const items = [{ json: { name: 'John Doe' } }, { json: { age: 30 } }]; const response = { body: {}, headers: {}, statusCode: 200, }; const result = await GenericFunctions_1.taskPostReceiceAction.call(mockThis, items, response); expect(result).toEqual([ { json: { name: 'John Doe', contactId: '12345' } }, { json: { age: 30, contactId: '12345' } }, ]); expect(mockThis.getNodeParameter).toHaveBeenCalledWith('contactId'); }); it('should return an empty array if items is empty', async () => { const items = []; const response = { body: {}, headers: {}, statusCode: 200, }; const result = await GenericFunctions_1.taskPostReceiceAction.call(mockThis, items, response); expect(result).toEqual([]); expect(mockThis.getNodeParameter).toHaveBeenCalledWith('contactId'); }); }); //# sourceMappingURL=TaskPostReceiceAction.test.js.map