proofchain/packages/api/test/envelope.test.ts
caelum0x e361a8dc22 feat: ProofChain platform — 64 contracts (11 modules), backend API, expanded web
- core: AddressBook registry, Roles lib, ProofChainAccess base, Pauser
- modules: provenance, payments/treasury, identity, reputation, finance/RWA,
  insurance, disputes+governance, esg/tokenization, marketplace, rewards
- @proofchain/api: 33 routers + event indexer (Supabase)
- web: 37 pages incl landing, explorer, finance, governance, esg, marketplace
- 704 forge tests + 449 vitest tests green; 61 ABIs exported

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-31 19:22:38 +03:00

25 lines
794 B
TypeScript

import { describe, expect, it } from 'vitest';
import { fail, ok, okPage } from '../src/lib/envelope.js';
describe('envelope', () => {
it('ok wraps data with null error', () => {
expect(ok({ a: 1 })).toEqual({ success: true, data: { a: 1 }, error: null });
});
it('okPage carries pagination meta', () => {
const env = okPage([1, 2], { total: 10, limit: 2, offset: 0 });
expect(env.success).toBe(true);
expect(env.data).toEqual([1, 2]);
expect(env.meta).toEqual({ total: 10, limit: 2, offset: 0 });
});
it('fail nulls data and carries the error payload', () => {
const env = fail({ code: 'NOT_FOUND', message: 'nope' });
expect(env).toEqual({
success: false,
data: null,
error: { code: 'NOT_FOUND', message: 'nope' },
});
});
});