1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

test(cli): add commands/run/test

This commit is contained in:
Divlo
2021-12-06 17:18:14 +01:00
parent 249bb3a367
commit cffaa9ec40
8 changed files with 128 additions and 12 deletions

View File

@ -101,6 +101,26 @@ Created by [@${githubUser}](https://github.com/${githubUser}) on ${dateString}.
)
})
it('fails with invalid language', async () => {
console.error = jest.fn()
const stream = new PassThrough()
const invalidLanguage = 'invalid'
const inputInvalidLanguage = `--language=${invalidLanguage}`
const exitCode = await cli.run(
[...input, inputChallenge, inputGitHubUser, inputSolution, inputInvalidLanguage],
{
stdin: process.stdin,
stdout: stream,
stderr: stream
}
)
stream.end()
expect(exitCode).toEqual(1)
expect(console.error).toHaveBeenCalledWith(
chalk.bold.red('Error:') + ' This programming language is not supported yet.'
)
})
it('fails without options', async () => {
const stream = new PassThrough()
const promise = getStream(stream)