n8n-nodes-highlevelv2
Version:
n8n community node for HighLevel v2 API integration - comprehensive CRM, marketing automation, and business management platform
54 lines • 2.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const GenericFunctions_1 = require("../GenericFunctions");
jest.mock('../GenericFunctions', () => ({
...jest.requireActual('../GenericFunctions'),
isEmailValid: jest.fn(),
isPhoneValid: jest.fn(),
}));
describe('validEmailAndPhonePreSendAction', () => {
let mockThis;
beforeEach(() => {
mockThis = {
getNode: jest.fn(() => ({
id: 'mock-node-id',
name: 'mock-node',
typeVersion: 1,
type: 'n8n-nodes-base.mockNode',
position: [0, 0],
parameters: {},
})),
};
jest.clearAllMocks();
});
it('should return requestOptions unchanged if email and phone are valid', async () => {
GenericFunctions_1.isEmailValid.mockReturnValue(true);
GenericFunctions_1.isPhoneValid.mockReturnValue(true);
const requestOptions = {
url: 'https://example.com/api',
body: {
email: 'valid@example.com',
phone: '+1234567890',
},
};
const result = await GenericFunctions_1.validEmailAndPhonePreSendAction.call(mockThis, requestOptions);
expect(result).toEqual(requestOptions);
});
it('should not modify requestOptions if no email or phone is provided', async () => {
const requestOptions = {
url: 'https://example.com/api',
body: {},
};
const result = await GenericFunctions_1.validEmailAndPhonePreSendAction.call(mockThis, requestOptions);
expect(result).toEqual(requestOptions);
});
it('should not modify requestOptions if body is undefined', async () => {
const requestOptions = {
url: 'https://example.com/api',
body: undefined,
};
const result = await GenericFunctions_1.validEmailAndPhonePreSendAction.call(mockThis, requestOptions);
expect(result).toEqual(requestOptions);
});
});
//# sourceMappingURL=ValidEmailAndPhonePreSendAction.test.js.map