feat: share choice modes and bracket editor
Verify mini program and deploy preview / verify-deploy (push) Successful in 25s
Verify mini program and deploy preview / verify-deploy (push) Successful in 25s
This commit is contained in:
@@ -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');
|
||||
});
|
||||
Reference in New Issue
Block a user