Files
bare-operating-system/packages/bare-os-coreutils/test/baretop-compose.test.mjs
T
2026-04-05 17:38:46 -04:00

27 lines
1.1 KiB
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 helpersPath = join(__dirname, '../lib/baretop-ui-helpers.js')
const composePath = join(__dirname, '../lib/baretop-compose.js')
const fixturePath = join(__dirname, 'fixtures/baretop-process-table.json')
test('bareTopComposeSmokeTestFrame golden lines', async (t) => {
const helpers = await readFile(helpersPath, 'utf8')
const compose = await readFile(composePath, 'utf8')
const ctx = createContext({})
runInContext(helpers, ctx)
runInContext(compose, ctx)
const raw = await readFile(fixturePath, 'utf8')
const pt = JSON.parse(raw)
const snap = { extra: { processTable: pt } }
const fr = ctx.bareTopComposeSmokeTestFrame(snap, 80)
t.ok(Array.isArray(fr.lines))
t.is(fr.lines[0], 'baretop-compose-smoke cols=80')
t.ok(fr.lines.some((l) => l.startsWith('process_rows=')))
t.ok(fr.meta && fr.meta.layoutVersion)
})