37 lines
875 B
TypeScript
37 lines
875 B
TypeScript
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
import {
|
|
ReadyGate,
|
|
type ReadyGateName,
|
|
} from '../../YouleNexus/assets/framework/platform/ready-gate.ts';
|
|
|
|
const GATES = [
|
|
'resources',
|
|
'config',
|
|
'socket',
|
|
'minimum-display',
|
|
] as const satisfies readonly ReadyGateName[];
|
|
|
|
for (let subset = 0; subset < 16; subset += 1) {
|
|
test(`ReadyGate is ${subset === 15 ? '' : 'not '}ready for subset ${subset.toString(2).padStart(4, '0')}`, () => {
|
|
const gate = new ReadyGate();
|
|
|
|
GATES.forEach((name, index) => {
|
|
if ((subset & (1 << index)) !== 0) gate.mark(name);
|
|
});
|
|
|
|
assert.equal(gate.ready, subset === 15);
|
|
});
|
|
}
|
|
|
|
test('ReadyGate duplicate marks are idempotent', () => {
|
|
const gate = new ReadyGate();
|
|
|
|
for (const name of GATES) {
|
|
gate.mark(name);
|
|
gate.mark(name);
|
|
}
|
|
|
|
assert.equal(gate.ready, true);
|
|
});
|