Skip to content

Commit

Permalink
feat: logger
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng authored and AbigailDeng committed Jun 26, 2024
1 parent 36bcf5b commit fdbd422
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ export default {

// The glob patterns Jest uses to detect test files
testMatch: [
'**/test/utils/Logger.test.js'
// '**/test/command/dappServer/socket-sign.test.js',
// '**/test/**/?(*.)+(spec|test).[jt]s?(x)'
// '**/test/utils/Logger.test.js'
'**/test/command/dappServer/socket-sign.test.js',
'**/test/**/?(*.)+(spec|test).[jt]s?(x)'
// "**/?(*.)+(spec|test).[tj]s?(x)"
],
testTimeout: 20000,
Expand Down
34 changes: 17 additions & 17 deletions test/utils/Logger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ describe('Logger', () => {
consoleLogSpy.mockRestore();
});

// test(`should log correctly formatted message`, () => {
// const logger = new Logger({ log: true, onlyWords: false, name: 'TestLogger' });
// const message = 'Test message';
// logger[fnName](message);
// const expectedPrefix = `[${level}]: `;
// const expectedLog = chalk.gray(`TestLogger ${expectedPrefix}${message}`);
// // second params: add spaces
// expect(consoleLogSpy).toHaveBeenCalledWith(expectedLog, '');
// });
// test(`should return correctly formatted chalk message`, () => {
// const logger = new Logger({ log: false, onlyWords: false, name: 'TestLogger' });
// const message = 'Test message';
// const result = logger[fnName](message);
// const expectedPrefix = `TestLogger [${level}]: `;
// const expectedChalk = chalk(chalk.gray(`${expectedPrefix}${message}`));
// expect(result.trim()).toEqual(expectedChalk);
// });
test(`should log correctly formatted message`, () => {
const logger = new Logger({ log: true, onlyWords: false, name: 'TestLogger' });
const message = 'Test message';
logger[fnName](message);
const expectedPrefix = `[${level}]: `;
const expectedLog = chalk.gray(`TestLogger ${expectedPrefix}${message}`);
// second params: add spaces
expect(consoleLogSpy).toHaveBeenCalledWith(expectedLog, '');
});
test(`should return correctly formatted chalk message`, () => {
const logger = new Logger({ log: false, onlyWords: false, name: 'TestLogger' });
const message = 'Test message';
const result = logger[fnName](message);
const expectedPrefix = `TestLogger [${level}]: `;
const expectedChalk = chalk(chalk.gray(`${expectedPrefix}${message}`));
expect(result.trim()).toEqual(expectedChalk);
});
test(`should log correctly formatted object message`, () => {
const logger = new Logger({ log: true, onlyWords: false, name: 'TestLogger' });
const message = { key: 'value' };
Expand Down

0 comments on commit fdbd422

Please sign in to comment.