Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
test: add cases for Logger class
Browse files Browse the repository at this point in the history
  • Loading branch information
upsetbit committed Jul 30, 2021
1 parent 1451395 commit e555bfc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/calculator.test.js → tests/Calculator.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals describe it expect */

import { Calculator } from '../src/calculator'
import Calculator from '@yant/Calculator'

describe('Calculator:', () => {
it('Should sum two values', () => {
Expand Down
40 changes: 40 additions & 0 deletions tests/Logger.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* globals jest describe it expect */

import Logger from '@yant/lib/Logger'

describe('Logger:', () => {
it('Should work with default config', () => {
const raise = jest.fn()

try {
const logger = new Logger()
logger.info('info message')
logger.warn('warn message')
logger.error('error message')
} catch (e) {
raise()
}

expect(raise).not.toHaveBeenCalled()
})

it('Should work with custom config', () => {
const raise = jest.fn()

try {
const devLogger = new Logger({ isDev: true })
devLogger.info('info message')
devLogger.warn('warn message')
devLogger.error('error message')

const prodLogger = new Logger({ isDev: false, label: 'jest' })
prodLogger.info('info message')
prodLogger.warn('warn message')
prodLogger.error('error message')
} catch (e) {
raise()
}

expect(raise).not.toHaveBeenCalled()
})
})

0 comments on commit e555bfc

Please sign in to comment.