import { describe, it, expect } from 'vitest' import { buildPairCommand, buildQrDataUrl, buildPairingArtifacts } from '../src/pairing.js' describe('pairing artifacts', () => { it('builds the ready-to-run pair command with the code and zone', () => { const cmd = buildPairCommand('ABCD-EFGH', 'terminal.yaojia.wang') expect(cmd).toBe('web-terminal-agent pair ABCD-EFGH --install --zone terminal.yaojia.wang') }) it('renders a PNG data URL for the code', async () => { const url = await buildQrDataUrl('ABCD-EFGH') expect(url.startsWith('data:image/png;base64,')).toBe(true) expect(url.length).toBeGreaterThan(100) }) it('combines an issued code into the full artifacts payload', async () => { const artifacts = await buildPairingArtifacts( { code: 'WXYZ-1234', expiresAt: '2026-05-01T00:00:00.000Z' }, 'z.example', ) expect(artifacts.code).toBe('WXYZ-1234') expect(artifacts.expiresAt).toBe('2026-05-01T00:00:00.000Z') expect(artifacts.pairCommand).toContain('WXYZ-1234') expect(artifacts.pairCommand).toContain('z.example') expect(artifacts.qrDataUrl.startsWith('data:image/png;base64,')).toBe(true) }) })