From 2c2d7d8777b456e62266edd24c9d71de13d3c18f Mon Sep 17 00:00:00 2001 From: "Angel M. Adames" Date: Sat, 2 Mar 2024 12:44:44 -0400 Subject: [PATCH] tests: Add utils/log.ts tests --- src/utils/log.ts | 20 ++++++++++---------- test/utils/log.test.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 test/utils/log.test.ts diff --git a/src/utils/log.ts b/src/utils/log.ts index 9c3fc57..875c034 100644 --- a/src/utils/log.ts +++ b/src/utils/log.ts @@ -1,24 +1,24 @@ import chalk from 'chalk'; const log = { - info: (...text: string[]): void => { - console.log(chalk.blue(text)); + info: (text: string[], ...optionalParams: string[]) => { + return console.log(chalk.blue(text), optionalParams); }, - success: (...text: string[]): void => { - console.log(chalk.green(text)); + success: (text: string[], ...optionalParams: string[]) => { + return console.log(chalk.green(text), optionalParams); }, - warning: (...text: string[]): void => { - console.log(chalk.yellow(text)); + warning: (text: string[], ...optionalParams: string[]) => { + return console.log(chalk.yellow(text), optionalParams); }, - dimmedWarning: (...text: string[]): void => { - console.log(chalk.dim.yellow(text)); + dimmedWarning: (text: string[], ...optionalParams: string[]) => { + return console.log(chalk.dim.yellow(text), optionalParams); }, - error: (...text: string[]): void => { - console.log(chalk.red(text)); + error: (text: string[], ...optionalParams: string[]) => { + return console.log(chalk.red(text), optionalParams); }, }; diff --git a/test/utils/log.test.ts b/test/utils/log.test.ts new file mode 100644 index 0000000..daa17b8 --- /dev/null +++ b/test/utils/log.test.ts @@ -0,0 +1,34 @@ +import { beforeAll, describe, expect, test } from 'bun:test'; +import log from '../../src/utils/log'; +import { omitConsoleLogs } from '../helpers'; + +describe('Utils: log', () => { + beforeAll(() => { + omitConsoleLogs(); + }); + + test('should log info message', () => { + const info = log.info(['info'], 'optional'); + expect(info).toBeUndefined(); + }); + + test('should log success message', () => { + const success = log.success(['success'], 'optional'); + expect(success).toBeUndefined(); + }); + + test('should log warning message', () => { + const warning = log.warning(['warning'], 'optional'); + expect(warning).toBeUndefined(); + }); + + test('should log dimmed warning message', () => { + const dimmedWarning = log.dimmedWarning(['dimmed warning'], 'optional'); + expect(dimmedWarning).toBeUndefined(); + }); + + test('should log error message', () => { + const error = log.error(['error'], 'optional'); + expect(error).toBeUndefined(); + }); +});