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/); }); });