30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { SEAT_IDS, SEATS, SEAT_GROUPS, seatLabel, isSeatId } from '../src/shared/roles.js'
|
|
|
|
test('十席固定且显示名两字', () => {
|
|
assert.equal(SEAT_IDS.length, 10)
|
|
assert.equal(new Set(SEAT_IDS).size, 10)
|
|
for (const id of SEAT_IDS) {
|
|
assert.equal(SEATS[id].id, id)
|
|
assert.equal(SEATS[id].label.length, 2, `${id} 显示名必须是两字`)
|
|
assert.ok(SEATS[id].duty && SEATS[id].duty.length > 0)
|
|
assert.ok(SEATS[id].responsibility && SEATS[id].responsibility.length > 0)
|
|
}
|
|
})
|
|
|
|
test('分组覆盖全部十席且结构正确', () => {
|
|
const all = [...SEAT_GROUPS.lead, ...SEAT_GROUPS.sansheng, ...SEAT_GROUPS.liubu].sort()
|
|
assert.deepEqual(all, [...SEAT_IDS].sort())
|
|
assert.deepEqual([...SEAT_GROUPS.lead], ['lead'])
|
|
assert.deepEqual([...SEAT_GROUPS.sansheng], ['zhongshu', 'shangshu', 'menxia'])
|
|
assert.equal(SEAT_GROUPS.liubu.length, 6)
|
|
})
|
|
|
|
test('seatLabel / isSeatId', () => {
|
|
assert.equal(seatLabel('gongbu'), '工部')
|
|
assert.equal(seatLabel('lead'), '丞相')
|
|
assert.ok(isSeatId('lead'))
|
|
assert.ok(!isSeatId('nope'))
|
|
})
|