Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
islathehut committed May 10, 2024
1 parent 6bccb85 commit 6f71eb3
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { QuietLogger } from '@quiet/logger'
import { storybookLog } from './storybookLog.function'

describe('storybookLog function', () => {
const consoleLogMessage = 'storybookLog called'

beforeEach(() => {
jest.spyOn(console, 'info')
jest.spyOn(QuietLogger.prototype, 'info')
})

afterEach(() => {
Expand All @@ -20,17 +21,17 @@ describe('storybookLog function', () => {
it('should call `logger.info` with passed message', () => {
storybookLog(consoleLogMessage)()

expect(console.info).toHaveBeenCalledWith(consoleLogMessage)
expect(console.info).toHaveBeenCalledTimes(1)
expect(QuietLogger.prototype.info).toHaveBeenCalledWith(consoleLogMessage)
expect(QuietLogger.prototype.info).toHaveBeenCalledTimes(1)
})

it('should call `console.info` with passed args', () => {
it('should call `logger.info` with passed args', () => {
const args = ['something', 5]
storybookLog(consoleLogMessage)(...args)

expect(console.info).toHaveBeenCalledWith(consoleLogMessage)
expect(console.info).toHaveBeenCalledWith(args[0])
expect(console.info).toHaveBeenCalledWith(args[1])
expect(console.info).toHaveBeenCalledTimes(3)
expect(QuietLogger.prototype.info).toHaveBeenCalledWith(consoleLogMessage)
expect(QuietLogger.prototype.info).toHaveBeenCalledWith(args[0])
expect(QuietLogger.prototype.info).toHaveBeenCalledWith(args[1])
expect(QuietLogger.prototype.info).toHaveBeenCalledTimes(3)
})
})

0 comments on commit 6f71eb3

Please sign in to comment.