sendi/tests/unit/cardActions.test.ts
jmcqueen d0a0dda2b8 Initial commit: Sendi 2.0 SMS gateway (Webex + Twilio)
Sendi is a Webex to Twilio SMS gateway written in TypeScript that runs
directly on Node 22.18+ via native type-stripping (no bundler/transpiler).
Each Webex space represents one external SMS contact; inbound MMS is
proxied both ways, with delivery-status cards for outbound sends.

Highlights:
- Express 5 HTTP surface for Twilio /sms and /callback (signature-validated)
- webex-node-bot-framework in websocket transport mode for bot control plane
- Prisma 6 + SQLite via better-sqlite3 driver adapter
- Zod-validated env with fail-fast startup and pino secret redaction
- Pino logging: pretty in dev, structured JSON in prod
- 13 vitest unit tests (phone normalization, Twilio signature validation,
  card action dispatch)
- Native --require preload patches Node 22's read-only globalThis.navigator
  so @webex/internal-media-core (transitive) can load

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 11:10:44 -04:00

24 lines
786 B
TypeScript

import { describe, expect, it } from 'vitest';
import { __testing } from '../../src/bot/cardActions.ts';
describe('cardAction handlers registry', () => {
it('registers a handler for every cardType emitted by CardBuilder', () => {
const expected = [
'sendMessage',
'updateContact',
'createNewContact',
'addContact',
'confirmDeleteContact',
'deleteContact',
'sendMessageHelp',
'cancel',
];
for (const cardType of expected) {
expect(__testing.handlers[cardType]).toBeTypeOf('function');
}
});
it('does not register handlers for unknown cardTypes', () => {
expect(__testing.handlers['nonexistent']).toBeUndefined();
});
});