Skip to content

Commit

Permalink
tests: Add utils/log.ts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angelmadames committed Mar 2, 2024
1 parent 07a8529 commit 2c2d7d8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/utils/log.ts
Original file line number Diff line number Diff line change
@@ -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);
},
};

Expand Down
34 changes: 34 additions & 0 deletions test/utils/log.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});

0 comments on commit 2c2d7d8

Please sign in to comment.