-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renaming parameters and adding command line tests. (#301)
* Adding command line tests. Signed-off-by: dblock <[email protected]> * Renamed tab size to width. Signed-off-by: dblock <[email protected]> * Extracted to ansi namespace. Signed-off-by: dblock <[email protected]> --------- Signed-off-by: dblock <[email protected]>
- Loading branch information
Showing
6 changed files
with
90 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export function b (text: string): string { return `\x1b[1m${text}\x1b[0m` } | ||
export function i (text: string): string { return `\x1b[3m${text}\x1b[0m` } | ||
|
||
export function padding (text: string, length: number, prefix: number = 0): string { | ||
const spaces = length - text.length > 0 ? ' '.repeat(length - text.length) : '' | ||
return `${' '.repeat(prefix)}${text}${spaces}` | ||
} | ||
|
||
export function green (text: string): string { return `\x1b[32m${text}\x1b[0m` } | ||
export function red (text: string): string { return `\x1b[31m${text}\x1b[0m` } | ||
export function yellow (text: string): string { return `\x1b[33m${text}\x1b[0m` } | ||
export function cyan (text: string): string { return `\x1b[36m${text}\x1b[0m` } | ||
export function gray (text: string): string { return `\x1b[90m${text}\x1b[0m` } | ||
export function magenta (text: string): string { return `\x1b[35m${text}\x1b[0m` } |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as ansi from '../../src/tester/Ansi' | ||
|
||
test('b', async () => { | ||
expect(ansi.b('xyz')).toEqual('\x1b[1mxyz\x1b[0m') | ||
}) | ||
|
||
test('i', async () => { | ||
expect(ansi.i('xyz')).toEqual('\x1b[3mxyz\x1b[0m') | ||
}) | ||
|
||
test.todo('padding') | ||
test.todo('green') | ||
test.todo('red') | ||
test.todo('yellow') | ||
test.todo('cyan') | ||
test.todo('gray') | ||
test.todo('magenta') |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$schema: ../json_schemas/test_story.schema.yaml | ||
|
||
chapters: [] |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { spawnSync } from 'child_process' | ||
import * as ansi from '../../src/tester/Ansi' | ||
|
||
const spec = (args: string[]): any => { | ||
const start = spawnSync('ts-node', ['tools/src/tester/start.ts'].concat(args), { | ||
env: { ...process.env, OPENSEARCH_PASSWORD: 'password' } | ||
}) | ||
return { | ||
stdout: start.stdout?.toString(), | ||
stderr: start.stderr?.toString() | ||
} | ||
} | ||
|
||
test('--help', async () => { | ||
expect(spec(['--help']).stdout).toContain('Usage: start [options]') | ||
}) | ||
|
||
test('--invalid', async () => { | ||
expect(spec(['--invalid']).stderr).toContain("error: unknown option '--invalid'") | ||
}) | ||
|
||
test('--tests', async () => { | ||
expect(spec(['--tests', 'tools/tests/tester/fixtures']).stdout).toContain( | ||
`${ansi.green('PASSED ')} ${ansi.cyan(ansi.b('empty.yaml'))}` | ||
) | ||
}) | ||
|
||
test.todo('--tab-width') | ||
test.todo('--verbose') | ||
test.todo('--spec') |