Some checks are pending
offline / test (push) Waiting to run
Each module has SUMMARY.md and NATS.md (who sends/receives, subject addresses, payload). Tests: splitter 3, worm 3, aggregator 2. Forgejo repos pushed separately; this commit keeps them in the monorepo.
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { splitRequest, sha256Hex } from '../src/splitRequest.js';
|
|
|
|
describe('splitRequest', () => {
|
|
it('hash-only has no archive puts', () => {
|
|
const out = splitRequest({ data: 'hello' });
|
|
assert.equal(out.chain.sha256, sha256Hex('hello'));
|
|
assert.equal(out.archivePuts.length, 0);
|
|
assert.equal(out.includeAttached, false);
|
|
});
|
|
|
|
it('splits public metadata and two files onto archive puts', () => {
|
|
const out = splitRequest({
|
|
data: 'hello',
|
|
publicMetadata: { title: 't' },
|
|
files: [
|
|
{ path: 'a.txt', data: 'A' },
|
|
{ path: 'b.txt', data: 'B' },
|
|
],
|
|
includeAttached: true,
|
|
});
|
|
assert.equal(out.archivePuts.length, 3);
|
|
assert.equal(out.archivePuts.filter((p) => p.kind === 'file').length, 2);
|
|
assert.equal(out.includeAttached, true);
|
|
assert.equal(out.chain.sha256, sha256Hex('hello'));
|
|
});
|
|
|
|
it('throws without data or sha256', () => {
|
|
assert.throws(() => splitRequest({}), /data or sha256/);
|
|
});
|
|
});
|