kilo-loop/test/verify.test.mjs
Vitali sharp8n 1eb9ec22c2 kilo loop
2026-09-13 19:29:03 +03:00

32 lines
1.2 KiB
JavaScript

import { test } from 'node:test'
import assert from 'node:assert/strict'
import { runVerify, verifyCommandFor, summariseVerify } from '../src/verify.mjs'
test('verifyCommandFor prefers the stage command over the global default', () => {
assert.equal(verifyCommandFor({ verify: 'pnpm test' }, { verify: 'global' }), 'pnpm test')
assert.equal(verifyCommandFor({}, { verify: 'global' }), 'global')
assert.equal(verifyCommandFor({}, {}), null)
})
test('runVerify reports success and captures output', async () => {
const res = await runVerify({ command: 'echo hello-verify', cwd: process.cwd() })
assert.equal(res.ok, true)
assert.equal(res.exitCode, 0)
assert.match(res.output, /hello-verify/)
})
test('runVerify reports a non-zero exit as failure', async () => {
const res = await runVerify({ command: 'exit 7', cwd: process.cwd() })
assert.equal(res.ok, false)
assert.equal(res.exitCode, 7)
assert.match(summariseVerify(res), /FAILED \(exit 7\)/)
})
test('runVerify times out and kills a hanging command', async () => {
const res = await runVerify({ command: 'sleep 5', cwd: process.cwd(), timeoutMs: 300 })
assert.equal(res.ok, false)
assert.equal(res.timedOut, true)
assert.match(summariseVerify(res), /TIMED OUT/)
})