Files
evening_detective_screen/electron/screen-plan.test.ts
T
2026-10-18 01:38:02 +07:00

25 lines
974 B
TypeScript

import assert from 'node:assert/strict'
import { test } from 'node:test'
import { parsePlan } from './screen-plan.js'
test('план: режимы protobuf, значения по умолчанию и UTF-8 ограничения сервера', () => {
assert.deepEqual(parsePlan(null), { steps: [], currentStep: 0 })
assert.equal(
parsePlan({ steps: [{ mode: 'SCREEN_MODE_TIMER', timerDurationSeconds: '60' }] }).steps[0]
?.timerLabel,
'Перерыв',
)
for (const value of [
{ steps: {} },
{ steps: [{ mode: 0 }] },
{ steps: [{ mode: 9 }] },
{ steps: [{ mode: 8, text: ' ' }] },
{ steps: [{ mode: 8, text: 'Я'.repeat(5001) }] },
{ steps: [{ mode: 7, timerDurationSeconds: 0 }] },
{ steps: [{ mode: 7, timerDurationSeconds: 86401 }] },
{ steps: [{ mode: 7, timerDurationSeconds: 1, timerLabel: 'Я'.repeat(101) }] },
{ steps: [{ mode: 1 }], currentStep: 1 },
])
assert.throws(() => parsePlan(value))
})