test: improve test coverage (#7181)

This commit is contained in:
Joshua Chen 2022-04-16 16:35:40 +08:00 committed by GitHub
parent 44966e19e9
commit f219a2ac90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 14 deletions

View file

@ -5,16 +5,16 @@
* LICENSE file in the root directory of this source tree.
*/
import chalk, {type Chalk} from 'chalk';
import chalk from 'chalk';
type InterpolatableValue = string | number | (string | number)[];
const path = (msg: unknown): string => chalk.cyan(chalk.underline(`"${msg}"`));
const url = (msg: unknown): string => chalk.cyan(chalk.underline(msg));
const name = (msg: unknown): string => chalk.blue(chalk.bold(msg));
const path = (msg: unknown): string => chalk.cyan.underline(`"${msg}"`);
const url = (msg: unknown): string => chalk.cyan.underline(msg);
const name = (msg: unknown): string => chalk.blue.bold(msg);
const code = (msg: unknown): string => chalk.cyan(`\`${msg}\``);
const subdue: Chalk = chalk.gray;
const num: Chalk = chalk.yellow;
const subdue = (msg: unknown): string => chalk.gray(msg);
const num = (msg: unknown): string => chalk.yellow(msg);
function interpolate(
msgs: TemplateStringsArray,
@ -69,7 +69,7 @@ function info(
): void;
function info(msg: unknown, ...values: InterpolatableValue[]): void {
console.info(
`${chalk.cyan(chalk.bold('[INFO]'))} ${
`${chalk.cyan.bold('[INFO]')} ${
values.length === 0
? stringify(msg)
: interpolate(msg as TemplateStringsArray, ...values)
@ -115,7 +115,7 @@ function success(
): void;
function success(msg: unknown, ...values: InterpolatableValue[]): void {
console.log(
`${chalk.green(chalk.bold('[SUCCESS]'))} ${
`${chalk.green.bold('[SUCCESS]')} ${
values.length === 0
? stringify(msg)
: interpolate(msg as TemplateStringsArray, ...values)