UNPKG

n8n-nodes-highlevelv2

Version:

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

89 lines 3.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const GenericFunctions_1 = require("../GenericFunctions"); describe('taskUpdatePreSendAction', () => { let mockThis; beforeEach(() => { mockThis = { getNodeParameter: jest.fn(), helpers: { httpRequestWithAuthentication: jest.fn(), }, }; }); it('should not modify requestOptions if title and dueDate are provided', async () => { const requestOptions = { url: 'https://api.example.com', body: { title: 'Task Title', dueDate: '2024-12-25T00:00:00Z', }, }; const result = await GenericFunctions_1.taskUpdatePreSendAction.call(mockThis, requestOptions); expect(result).toEqual(requestOptions); }); it('should fetch missing title and dueDate from the API', async () => { var _a; mockThis.getNodeParameter.mockReturnValueOnce('123').mockReturnValueOnce('456'); const mockApiResponse = { title: 'Fetched Task Title', dueDate: '2024-12-25T02:00:00+02:00', }; ((_a = mockThis.helpers) === null || _a === void 0 ? void 0 : _a.httpRequestWithAuthentication).mockResolvedValue(mockApiResponse); const requestOptions = { url: 'https://api.example.com', body: { title: undefined, dueDate: undefined, }, }; const result = await GenericFunctions_1.taskUpdatePreSendAction.call(mockThis, requestOptions); expect(result.body).toEqual({ title: 'Fetched Task Title', dueDate: '2024-12-25T00:00:00+00:00', }); }); it('should only fetch title if dueDate is provided', async () => { var _a; mockThis.getNodeParameter.mockReturnValueOnce('123').mockReturnValueOnce('456'); const mockApiResponse = { title: 'Fetched Task Title', dueDate: '2024-12-25T02:00:00+02:00', }; ((_a = mockThis.helpers) === null || _a === void 0 ? void 0 : _a.httpRequestWithAuthentication).mockResolvedValue(mockApiResponse); const requestOptions = { url: 'https://api.example.com', body: { title: undefined, dueDate: '2024-12-24T00:00:00Z', }, }; const result = await GenericFunctions_1.taskUpdatePreSendAction.call(mockThis, requestOptions); expect(result.body).toEqual({ title: 'Fetched Task Title', dueDate: '2024-12-24T00:00:00Z', }); }); it('should only fetch dueDate if title is provided', async () => { var _a; mockThis.getNodeParameter.mockReturnValueOnce('123').mockReturnValueOnce('456'); const mockApiResponse = { title: 'Fetched Task Title', dueDate: '2024-12-25T02:00:00+02:00', }; ((_a = mockThis.helpers) === null || _a === void 0 ? void 0 : _a.httpRequestWithAuthentication).mockResolvedValue(mockApiResponse); const requestOptions = { url: 'https://api.example.com', body: { title: 'Existing Task Title', dueDate: undefined, }, }; const result = await GenericFunctions_1.taskUpdatePreSendAction.call(mockThis, requestOptions); expect(result.body).toEqual({ title: 'Existing Task Title', dueDate: '2024-12-25T00:00:00+00:00', }); }); }); //# sourceMappingURL=TaskUpdatePreSendAction.test.js.map