Start working on tests.

This commit is contained in:
Joshua Bemenderfer
2023-02-07 13:33:23 -05:00
parent ea6eb7bd94
commit ac821e448d
29 changed files with 154 additions and 121 deletions

23
packages/js/test/index.js Normal file
View File

@@ -0,0 +1,23 @@
import { createLineData, parseLine, useDocument } from '@terrace/core'
import { createStdinReader } from '@terrace/core/readers/node-readline'
const testName = process.argv[2]
const tests = {
'linedata:basic': async () => {
const { level, line, head, tail, next } = useDocument(createStdinReader())
while(await next()) {
console.log(`level: ${level()} | head: ${head()} | tail: ${tail()} | line: ${line()}`)
}
},
'linedata:tabs': async () => {
const { level, line, head, tail, next } = useDocument(createStdinReader(), '\t')
while(await next()) {
console.log(`level: ${level()} | head: ${head()} | tail: ${tail()} | line: ${line()}`)
}
}
}
const test = tests[testName]
await test()