Initial import of verae-nats-process from zapier monorepo

This commit is contained in:
George Lambert 2026-09-11 13:51:41 -04:00
commit cc2dcce9a3
10 changed files with 198 additions and 0 deletions

21
test/handle.test.js Normal file
View file

@ -0,0 +1,21 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { handle } from '../src/handle.js';
import { SUBJECTS } from '../src/subjects.js';
describe('verae-nats-process template', () => {
it('uses the verae.area.resource.action address pattern', () => {
assert.equal(SUBJECTS.IN, 'verae.example.process.in');
assert.equal(SUBJECTS.OUT, 'verae.example.process.out');
assert.match(SUBJECTS.reply('abc'), /^verae\.example\.process\.reply\.abc$/);
});
it('handle requires correlation and is idempotent-shaped', () => {
assert.throws(() => handle({}), /correlationId/);
const a = handle({ correlationId: 'c1', payload: { q: 1 } });
const b = handle({ correlationId: 'c1', payload: { q: 1 } });
assert.equal(a.ok, true);
assert.equal(a.correlationId, b.correlationId);
assert.equal(a.echo.q, 1);
});
});