+3
-7
@@ -1,8 +1,8 @@
|
||||
import { type WebhookFormValues } from '@/settings/developers/validation-schemas/webhookFormSchema';
|
||||
import {
|
||||
createWebhookCreateInput,
|
||||
createWebhookUpdateInput,
|
||||
} from '@/settings/developers/utils/createWebhookInput';
|
||||
import { type WebhookFormValues } from '@/settings/developers/validation-schemas/webhookFormSchema';
|
||||
|
||||
describe('createWebhookInput', () => {
|
||||
const mockFormValues: WebhookFormValues = {
|
||||
@@ -43,11 +43,9 @@ describe('createWebhookInput', () => {
|
||||
|
||||
describe('createWebhookUpdateInput', () => {
|
||||
it('should create input for webhook update with id', () => {
|
||||
const webhookId = 'test-webhook-id';
|
||||
const result = createWebhookUpdateInput(mockFormValues, webhookId);
|
||||
const result = createWebhookUpdateInput(mockFormValues);
|
||||
|
||||
expect(result).toEqual({
|
||||
id: 'test-webhook-id',
|
||||
targetUrl: 'https://test.com/webhook',
|
||||
operations: ['person.created', 'company.updated'],
|
||||
description: 'Test webhook',
|
||||
@@ -60,12 +58,10 @@ describe('createWebhookInput', () => {
|
||||
...mockFormValues,
|
||||
targetUrl: ' https://example.com ',
|
||||
};
|
||||
const webhookId = 'test-webhook-id';
|
||||
|
||||
const result = createWebhookUpdateInput(formValues, webhookId);
|
||||
const result = createWebhookUpdateInput(formValues);
|
||||
|
||||
expect(result.targetUrl).toBe('https://example.com');
|
||||
expect(result.id).toBe('test-webhook-id');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,14 +12,10 @@ export const createWebhookCreateInput = (formValues: WebhookFormValues) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const createWebhookUpdateInput = (
|
||||
formValues: WebhookFormValues,
|
||||
webhookId: string,
|
||||
) => {
|
||||
export const createWebhookUpdateInput = (formValues: WebhookFormValues) => {
|
||||
const cleanedOperations = cleanAndFormatOperations(formValues.operations);
|
||||
|
||||
return {
|
||||
id: webhookId,
|
||||
targetUrl: formValues.targetUrl.trim(),
|
||||
operations: cleanedOperations,
|
||||
description: formValues.description,
|
||||
|
||||
Reference in New Issue
Block a user