Files
bare-operating-system/packages/bare-os-coreutils/test/baretop-interaction-latency.test.mjs
T
2026-04-26 08:28:12 -04:00

25 lines
936 B
JavaScript

import test from 'brittle'
import { readFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { createContext, runInContext } from 'node:vm'
const __dirname = dirname(fileURLToPath(import.meta.url))
const tuiPath = join(__dirname, '../lib/baretop-tui.js')
test('bareTopModalSleepMs prioritizes buffered input', async (t) => {
const src = await readFile(tuiPath, 'utf8')
const ctx = createContext({})
runInContext(src, ctx)
t.is(typeof ctx.bareTopModalSleepMs, 'function')
t.ok(ctx.bareTopModalSleepMs(0, 0) >= 10)
t.ok(ctx.bareTopModalSleepMs(4, 0) <= 8)
t.ok(ctx.bareTopModalSleepMs(80, 0) <= 2)
})
test('baretop source includes reduced-motion toggle handling', async (t) => {
const src = await readFile(tuiPath, 'utf8')
t.ok(src.includes('BARE_TOP_REDUCED_MOTION'))
t.ok(src.includes('const logSparkEff = reducedMotion ? false : logSpark'))
})