|
| 1 | +/** |
| 2 | + * @vitest-environment node |
| 3 | + */ |
| 4 | +import { describe, expect, it } from 'vitest' |
| 5 | +import { ZeliqBlock } from '@/blocks/blocks/zeliq' |
| 6 | + |
| 7 | +function mapParams(params: Record<string, unknown>): Record<string, unknown> { |
| 8 | + const mapper = ZeliqBlock.tools.config.params |
| 9 | + if (!mapper) throw new Error('Zeliq block is missing tools.config.params') |
| 10 | + return mapper(params) |
| 11 | +} |
| 12 | + |
| 13 | +describe('Zeliq block tool wiring', () => { |
| 14 | + it('maps only the active LinkedIn email lookup fields', () => { |
| 15 | + expect( |
| 16 | + mapParams({ |
| 17 | + operation: 'zeliq_enrich_email', |
| 18 | + emailLookupMethod: 'linkedin', |
| 19 | + apiKey: 'test-key', |
| 20 | + callbackUrl: 'https://example.com/callback', |
| 21 | + emailLinkedInUrl: 'https://linkedin.com/in/active', |
| 22 | + emailFirstName: 'Stale', |
| 23 | + emailLastName: 'Person', |
| 24 | + emailDomain: 'stale.example', |
| 25 | + phoneLookupMethod: 'email', |
| 26 | + phoneEmail: 'stale@example.com', |
| 27 | + }) |
| 28 | + ).toEqual({ |
| 29 | + apiKey: 'test-key', |
| 30 | + callbackUrl: 'https://example.com/callback', |
| 31 | + linkedinUrl: 'https://linkedin.com/in/active', |
| 32 | + }) |
| 33 | + }) |
| 34 | + |
| 35 | + it('maps only the active person-details email lookup fields', () => { |
| 36 | + expect( |
| 37 | + mapParams({ |
| 38 | + operation: 'zeliq_enrich_email', |
| 39 | + emailLookupMethod: 'person_details', |
| 40 | + apiKey: 'test-key', |
| 41 | + callbackUrl: 'https://example.com/callback', |
| 42 | + emailLinkedInUrl: 'https://linkedin.com/in/stale', |
| 43 | + emailFirstName: 'Jane', |
| 44 | + emailLastName: 'Doe', |
| 45 | + emailCompany: 'Example Inc', |
| 46 | + emailDomain: 'example.com', |
| 47 | + phoneLinkedInUrl: 'https://linkedin.com/in/stale-phone', |
| 48 | + }) |
| 49 | + ).toEqual({ |
| 50 | + apiKey: 'test-key', |
| 51 | + callbackUrl: 'https://example.com/callback', |
| 52 | + firstName: 'Jane', |
| 53 | + lastName: 'Doe', |
| 54 | + company: 'Example Inc', |
| 55 | + domain: 'example.com', |
| 56 | + }) |
| 57 | + }) |
| 58 | + |
| 59 | + it('maps only the active phone lookup fields', () => { |
| 60 | + expect( |
| 61 | + mapParams({ |
| 62 | + operation: 'zeliq_enrich_phone', |
| 63 | + phoneLookupMethod: 'email', |
| 64 | + apiKey: 'test-key', |
| 65 | + callbackUrl: 'https://example.com/callback', |
| 66 | + phoneEmail: 'active@example.com', |
| 67 | + phoneLinkedInUrl: 'https://linkedin.com/in/stale-phone', |
| 68 | + emailLookupMethod: 'linkedin', |
| 69 | + emailLinkedInUrl: 'https://linkedin.com/in/stale-email', |
| 70 | + }) |
| 71 | + ).toEqual({ |
| 72 | + apiKey: 'test-key', |
| 73 | + callbackUrl: 'https://example.com/callback', |
| 74 | + email: 'active@example.com', |
| 75 | + }) |
| 76 | + }) |
| 77 | + |
| 78 | + it('fails fast for unknown operations and lookup methods', () => { |
| 79 | + expect(() => mapParams({ operation: 'unsupported' })).toThrow(/Unsupported Zeliq operation/) |
| 80 | + expect(() => |
| 81 | + mapParams({ operation: 'zeliq_enrich_email', emailLookupMethod: 'unsupported' }) |
| 82 | + ).toThrow(/Unsupported Zeliq email lookup method/) |
| 83 | + expect(() => |
| 84 | + mapParams({ operation: 'zeliq_enrich_phone', phoneLookupMethod: 'unsupported' }) |
| 85 | + ).toThrow(/Unsupported Zeliq phone lookup method/) |
| 86 | + }) |
| 87 | +}) |
0 commit comments