Skip to main content
Glama
attribute-null-value.test.tsβ€’2.96 kB
import { describe, it, expect, beforeEach, vi } from 'vitest'; import { formatAllAttributes } from '../../src/api/attribute-types'; // Mock dependencies const mockGet = vi.fn() as any; vi.mock('../../src/api/attio-client', () => ({ getAttioClient: vi.fn(() => ({ get: mockGet, })), })); // Setup mock response beforeEach(() => { (mockGet as any).mockResolvedValue({ data: { data: [ { api_slug: 'body_contouring', type: 'text', is_multiselect: false, }, { api_slug: 'name', type: 'text', is_required: true, }, { api_slug: 'services', type: 'text', is_multiselect: false, }, ], }, }); }); describe('formatAllAttributes - null value handling', () => { it('should preserve null values in formatted output', async () => { const attributes = { body_contouring: null, name: 'Test Company', services: 'Test services', }; const formatted = await formatAllAttributes('companies', attributes); // The key assertion: null values should be preserved expect(formatted).toHaveProperty('body_contouring'); expect(formatted.body_contouring).toBe(null); // Other values should be formatted normally expect(formatted).toHaveProperty('name'); expect(formatted).toHaveProperty('services'); }); it('should handle mixed null, undefined, and regular values', async () => { const attributes = { body_contouring: null, name: 'Test Company', services: undefined, website: 'https://example.com', }; const formatted = await formatAllAttributes('companies', attributes); // null values should be preserved expect(formatted).toHaveProperty('body_contouring'); expect(formatted.body_contouring).toBe(null); // undefined values should be omitted expect(formatted).not.toHaveProperty('services'); // regular values should be formatted expect(formatted).toHaveProperty('name'); expect(formatted).toHaveProperty('website'); }); it('should handle objects with only null values', async () => { const attributes = { body_contouring: null, services: null, }; const formatted = await formatAllAttributes('companies', attributes); // All null values should be preserved expect(formatted).toHaveProperty('body_contouring'); expect(formatted.body_contouring).toBe(null); expect(formatted).toHaveProperty('services'); expect(formatted.services).toBe(null); }); }); describe('updateCompanyAttribute - Issue #97 fix', () => { it('should successfully update attribute to null without error', async () => { // This test would require more complex mocking of the entire flow // but the key behavior is tested above - that null values are preserved // through the formatAllAttributes function expect(true).toBe(true); }); });

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