// Generated, do not edit. sha256:58db111ac78e4a42ffb2a0d70bf951d76a2b49cabbec0d9b026ed5ba61ba33b8 import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { createRegistry } from '../../shared/registry.js'; describe('createRegistry', () => { it('refuses an id twice, an entry without id, and what validate rejects', () => { const r = createRegistry('test', { validate: e => { if (!e.run) throw new Error('no run'); } }); r.register({ id: 'a', run: () => 1 }); assert.throws(() => r.register({ id: 'a', run: () => 2 }), /twice/); assert.throws(() => r.register({ run: () => 3 }), /needs an id/); assert.throws(() => r.register({ id: 'b' }), /no run/); assert.deepEqual(r.list().map(e => e.id), ['a'], 'a refused entry is not half in'); }); it('gives null for what is not registered, and a frozen entry with a feature', () => { const r = createRegistry('test'); assert.equal(r.get('x'), null); r.register({ id: 'x' }); assert.equal(r.get('x').feature, null); assert.ok(Object.isFrozen(r.get('x'))); }); it('lists in registration order', () => { const r = createRegistry('test'); for (const id of ['c', 'a', 'b']) r.register({ id }); assert.deepEqual(r.list().map(e => e.id), ['c', 'a', 'b']); }); });