Initial import of verae-nats-process from zapier monorepo
This commit is contained in:
commit
68e54c063c
10 changed files with 198 additions and 0 deletions
21
test/handle.test.js
Normal file
21
test/handle.test.js
Normal 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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue