You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB

import { readFile } from 'fs/promises'
import { promisify } from 'util'
import * as cp from 'child_process'
const exec = promisify(cp.exec)
export const tests = []
export const setup = async ({ path }) => {
const run = async word => {
await exec(`node ${path} ${word}`)
const fileContent = await readFile(
'verydisco-forever.txt',
'utf8',
)
return { data: fileContent }
}
return { run }
}
tests.push(async ({ ctx, eq }) => {
const { data } = await ctx.run(`discovery`)
return eq(data, 'verydisco')
})
tests.push(async ({ ctx, eq }) => {
const { data } = await ctx.run(`"kiss cool"`)
return eq(data, 'sski olco')
})
tests.push(async ({ ctx, eq }) => {
const { data } = await ctx.run(`kiss cool`)
return eq(data, 'sski')
})
tests.push(async ({ ctx, eq }) => {
const { data } = await ctx.run(`"Node is awesome"`)
return eq(data, 'deNo si omeawes')
})
4 years ago
tests.push(async ({ ctx, eq, randStr }) => {
const tic = randStr(7)
const tac = randStr(7)
const { data } = await ctx.run(`"${tic}${tac}"`)
return eq(data, `${tac}${tic}`)
})
4 years ago
tests.push(async ({ ctx, eq, randStr }) => {
const ying = randStr(8)
const yang = randStr(7)
const { data } = await ctx.run(`"${ying}${yang}"`)
return eq(data, `${yang}${ying}`)
})
4 years ago
tests.push(async ({ ctx, eq, randStr }) => {
const tic = randStr(5)
const tac = randStr(5)
const ying = randStr(3)
const yang = randStr(2)
const { data } = await ctx.run(`"${tic}${tac} ${ying}${yang}"`)
return eq(data, `${tac}${tic} ${yang}${ying}`)
})
Object.freeze(tests)