Terrace/test/test-runner.test.js
2023-02-05 07:44:11 -05:00

37 lines
921 B
JavaScript

import { expect } from 'chai'
import fs from 'node:fs/promises'
import { useDocument } from '@terrace/core'
import { createReadlineReader } from '@terrace/core/readers/node-readline'
async function loadTest(path) {
const { next, level, head, tail, line, match } = useDocument(createReadlineReader(path))
const test = { input: [], output: [] }
while (await next()) {
if (match('input')) {
const rootLevel = level()
while (await next(rootLevel)) {
test.input.push(line(rootLevel))
}
}
if (match('output')) {
const rootLevel = level()
while (await next(rootLevel)) {
test.input.push(line(rootLevel))
}
}
}
return { input: test.input.join('\n'), output: test.output.join('\n') }
}
it('Runs a basic test', async () => {
const { input, output } = await loadTest('./basic.test.tce', 'utf-8')
console.log(input)
expect(1).to.equal(1)
})