-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: migrate to node test runner (#312)
- Loading branch information
Showing
9 changed files
with
245 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,70 @@ | ||
'use strict' | ||
|
||
const t = require('tap') | ||
const { test } = require('node:test') | ||
const h = require('./helper') | ||
const pkg = require('../package.json') | ||
|
||
t.test('defaults to help', t => { | ||
test('defaults to help', t => { | ||
t.plan(1) | ||
const cli = h.execute('', []) | ||
cli.stdout.setEncoding('utf8') | ||
const { promise, resolve } = h.withResolvers() | ||
cli.stdout.on('data', output => { | ||
t.match(output, h.readFileHelp('help')) | ||
t.assert.deepStrictEqual(output, h.readFileHelp('help')) | ||
resolve() | ||
}) | ||
|
||
return promise | ||
}) | ||
|
||
t.test('version', t => { | ||
test('version', t => { | ||
t.plan(1) | ||
const cli = h.execute('', ['--version']) | ||
cli.stdout.setEncoding('utf8') | ||
const { promise, resolve } = h.withResolvers() | ||
cli.stdout.on('data', output => { | ||
t.match(output, pkg.version) | ||
t.assert.ok(output.includes(pkg.version)) | ||
resolve() | ||
}) | ||
|
||
return promise | ||
}) | ||
|
||
t.test('version strict', t => { | ||
test('version strict', t => { | ||
t.plan(1) | ||
const cli = h.execute('', ['-v']) | ||
cli.stdout.setEncoding('utf8') | ||
const { promise, resolve } = h.withResolvers() | ||
cli.stdout.on('data', output => { | ||
t.match(output, pkg.version) | ||
t.assert.ok(output.includes(pkg.version)) | ||
resolve() | ||
}) | ||
|
||
return promise | ||
}) | ||
|
||
t.test('version win over help', t => { | ||
test('version win over help', t => { | ||
t.plan(1) | ||
const cli = h.execute('', ['-h', '-v']) | ||
cli.stdout.setEncoding('utf8') | ||
const { promise, resolve } = h.withResolvers() | ||
cli.stdout.on('data', output => { | ||
t.match(output, pkg.version) | ||
t.assert.ok(output.includes(pkg.version)) | ||
resolve() | ||
}) | ||
|
||
return promise | ||
}) | ||
|
||
t.test('config error', t => { | ||
test('config error', t => { | ||
t.plan(1) | ||
const cli = h.execute('config', ['--arg', 'wrong']) | ||
cli.stdout.setEncoding('utf8') | ||
const { promise, resolve } = h.withResolvers() | ||
cli.stdout.on('data', output => { | ||
t.match(output, /arg must be equal to one of the allowed values/) | ||
t.assert.match(output, /arg must be equal to one of the allowed values/) | ||
resolve() | ||
}) | ||
|
||
return promise | ||
}) |
Oops, something went wrong.