feat: share choice modes and bracket editor
Verify mini program and deploy preview / verify-deploy (push) Successful in 25s

This commit is contained in:
2026-09-19 04:12:09 +08:00
parent 23f246e792
commit 5a16113a6d
15 changed files with 455 additions and 43 deletions
+25
View File
@@ -0,0 +1,25 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const bracket = require('../utils/bracket');
function candidates(count) {
return Array.from({ length: count }, (_, index) => ({ id: String(index), name: `C${index}` }));
}
test('supports selecting several matches in the same round', () => {
const state = bracket.create(candidates(4));
assert.equal(bracket.chooseAt(state, 1, state.matches[1].right), false);
assert.equal(state.round, 1);
assert.equal(bracket.chooseAt(state, 0, state.matches[0].left), false);
assert.equal(state.round, 2);
assert.equal(bracket.choose(state, state.matches[0].left), true);
assert.equal(state.pool.length, 1);
assert.equal(state.decisions.length, 3);
});
test('odd candidates receive a deterministic bye', () => {
const state = bracket.create(candidates(3));
bracket.chooseAt(state, 0, state.matches[0].left);
assert.equal(state.round, 2);
assert.equal(state.matches[0].right.id, '2');
});