Some checks are pending
offline / test (push) Waiting to run
Signup registers/binds a Verae central user and stores veraeUserId. Public access stays the zappier API key. Chain JWTs stay server-side behind tokenRef. Authz, billing, and jobs.watch carry veraeUserId.
21 lines
944 B
JavaScript
21 lines
944 B
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { AccountBooks, handle } from '../src/books.js';
|
|
import { SUBJECTS } from '../src/subjects.js';
|
|
|
|
test('adjust credits prepaid and statement lists credits usage payments', () => {
|
|
const books = new AccountBooks();
|
|
handle(
|
|
SUBJECTS.BALANCE_ADJUST,
|
|
{ customerId: 'c1', veraeUserId: 'vu_abc', cents: 500, reason: 'goodwill', agent: 'cs' },
|
|
books,
|
|
);
|
|
handle(SUBJECTS.USAGE_RECORDED, { customerId: 'c1', endpointId: 'timestamp', cents: 4 }, books);
|
|
handle(SUBJECTS.PAYMENT_RECORDED, { customerId: 'c1', cents: 1000, reason: 'reload' }, books);
|
|
const st = handle(SUBJECTS.STATEMENT_GET, { customerId: 'c1' }, books);
|
|
assert.equal(st.prepaidCents, 1496);
|
|
assert.equal(st.veraeUserId, 'vu_abc');
|
|
assert.equal(st.credits[0].cents, 500);
|
|
assert.equal(st.usage[0].endpointId, 'timestamp');
|
|
assert.equal(st.payments[0].kind, 'payment');
|
|
});
|