43 lines
1.9 KiB
JavaScript
43 lines
1.9 KiB
JavaScript
import test from 'brittle'
|
|
import { readFile } from 'node:fs/promises'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const tuiPath = join(__dirname, '../lib/baretop-tui.js')
|
|
const kernelBaretop = join(__dirname, '../../../kernel/bin/baretop')
|
|
const kernelBtop = join(__dirname, '../../../kernel/bin/btop')
|
|
|
|
test('baretop-tui uses alternate screen teardown pattern', async (t) => {
|
|
const src = await readFile(tuiPath, 'utf8')
|
|
t.ok(src.includes('[?1049h'), 'expected alternate-screen enter')
|
|
t.ok(src.includes('[?1049l'), 'expected alternate-screen leave in finally')
|
|
t.ok(src.includes('BARE_TOP_NO_ALTSCREEN'), 'expected env gate')
|
|
t.ok(
|
|
(src.match(/\\x1b\[2J\\x1b\[H/g) || []).length >= 1,
|
|
'expected full clear fallback in finally'
|
|
)
|
|
t.ok(
|
|
src.includes('incrementalFrameDiff'),
|
|
'expected incremental frame diff gate in tui source'
|
|
)
|
|
})
|
|
|
|
test('shipped kernel/bin/baretop includes snapshot + TUI', async (t) => {
|
|
const bin = await readFile(kernelBaretop, 'utf8')
|
|
t.ok(bin.includes('bareTopFetchSnapshot'), 'expected snapshot in bundle')
|
|
t.ok(bin.includes('bareOsRunBareTopTui'), 'expected TUI runner in bundle')
|
|
t.ok(bin.includes('[?1049l'), 'expected teardown in bundle')
|
|
t.ok(bin.includes('BARE_TOP_THEME'), 'expected theme env in bundle')
|
|
t.ok(bin.includes('bareTopStrings'), 'expected i18n string table in bundle')
|
|
t.ok(bin.includes('SIGWINCH'), 'expected resize hook in bundle')
|
|
t.ok(bin.includes('bareTopParseMeminfoMetrics'), 'expected UI helpers in bundle')
|
|
t.ok(bin.includes('TAB_PROC'), 'expected processes tab in bundle')
|
|
})
|
|
|
|
test('shipped kernel/bin/btop matches baretop bundle', async (t) => {
|
|
const a = await readFile(kernelBaretop, 'utf8')
|
|
const b = await readFile(kernelBtop, 'utf8')
|
|
t.is(a, b, 'btop should be same concatenated bundle as baretop')
|
|
})
|