Skip to main content
Glama
data-normalizers.test.ts1.92 kB
/** * Tests for data normalizer validation logic - Issue #895 */ import { describe, test, expect } from 'vitest'; import { normalizePersonValues } from '@services/create/data-normalizers'; describe('normalizePersonValues - Issue #895 Validation', () => { test('should throw error when both name and email are missing', () => { const input = { job_title: 'Software Engineer' }; expect(() => normalizePersonValues(input)).toThrow( 'missing required parameter: name (cannot be derived from email_addresses when email is also missing)' ); }); test('should throw error when empty object is provided', () => { const input = {}; expect(() => normalizePersonValues(input)).toThrow( 'missing required parameter: name (cannot be derived from email_addresses when email is also missing)' ); }); test('should derive name from email when name is missing but email exists', () => { const input = { email_addresses: ['john.doe@example.com'] }; const result = normalizePersonValues(input); expect(result.name).toEqual([ expect.objectContaining({ first_name: 'john', last_name: 'doe', full_name: 'john doe', }), ]); }); test('should not throw when name is provided without email', () => { const input = { name: 'Jane Smith' }; expect(() => normalizePersonValues(input)).not.toThrow(); const result = normalizePersonValues(input); expect(result.name).toBeDefined(); expect(result.email_addresses).toBeUndefined(); }); test('should accept name with email addresses', () => { const input = { name: 'Bob Wilson', email_addresses: ['bob@example.com'], }; expect(() => normalizePersonValues(input)).not.toThrow(); const result = normalizePersonValues(input); expect(result.name).toBeDefined(); expect(result.email_addresses).toEqual(['bob@example.com']); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kesslerio/attio-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server