feat: rule-pack contract v2 (params + summary) and registry listing

This commit is contained in:
2026-07-20 16:15:02 +01:00
parent fee86b8dd1
commit 4ebf8d3994
5 changed files with 34 additions and 4 deletions
+9
View File
@@ -0,0 +1,9 @@
import { describe, it, expect } from 'vitest';
import { getRulePack, listRulePacks } from '../../src/dice/rulepacks/index.js';
describe('rule-pack registry', () => {
it('lists registered packs as {id,label}', () => {
const packs = listRulePacks();
expect(packs.some((p) => p.id === 'year-zero' && typeof p.label === 'string')).toBe(true);
});
});
+12
View File
@@ -24,3 +24,15 @@ describe('year-zero rule-pack', () => {
expect(getRulePack('x')).toBe(custom);
});
});
describe('year-zero contract v2', () => {
it('exposes an empty params list and a summary string', () => {
expect(yearZero.params).toEqual([]);
expect(yearZero.summary({ successes: 2, ones: 1 })).toBe('2 successes · 1 stress');
expect(yearZero.summary({ successes: 1, ones: 0 })).toBe('1 success');
});
it('interpret ignores a params argument', () => {
const v = yearZero.interpret([{ sides: 8, value: 8 }], { anything: true });
expect(v.successes).toBe(1);
});
});