Files
twenty/packages/twenty-shared/src/metadata/__tests__/computeMetadataNameFromLabel.test.ts
T
martmull da064d5e88 Support define is tool logic function (#17926)
- supports isTool and timeout settings in defineLogicFunction in apps
and in setting tabs definition
- compute for all toolInputSchema for logic funciton, in settings and in
code steps

<img width="991" height="802" alt="image"
src="https://github.com/user-attachments/assets/05dc1221-cac9-45a3-87b0-3b13161446fd"
/>
2026-02-16 10:43:29 +01:00

36 lines
1.0 KiB
TypeScript

import { computeMetadataNameFromLabel } from '@/metadata/compute-metadata-name-from-label.util';
describe('computeMetadataNameFromLabel', () => {
it('should convert a label to camelCase', () => {
expect(computeMetadataNameFromLabel({ label: 'My Custom Field' })).toBe(
'myCustomField',
);
});
it('should return empty string for empty label', () => {
expect(computeMetadataNameFromLabel({ label: '' })).toBe('');
});
it('should prefix numeric labels with n', () => {
expect(computeMetadataNameFromLabel({ label: '123 Field' })).toBe(
'n123Field',
);
});
it('should add Custom suffix for reserved words', () => {
const result = computeMetadataNameFromLabel({ label: 'Name' });
expect(typeof result).toBe('string');
expect(result.length).toBeGreaterThan(0);
});
it('should skip custom suffix when applyCustomSuffix is false', () => {
const result = computeMetadataNameFromLabel({
label: 'My Field',
applyCustomSuffix: false,
});
expect(result).toBe('myField');
});
});