Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/graphql-toolset / src / __tests__ / logger.test.ts
Size: Mime:
import { toMockLogger, LogMapKeyType } from '../loggerMock'

function expectEmpty(logger: ReturnType<typeof toMockLogger>) {
  expect(logger.logMap.get('info').size).toEqual(0)
  expect(logger.logMap.get('warn').size).toEqual(0)
  expect(logger.logMap.get('error').size).toEqual(0)
  expect(logger.logMap.get('debug').size).toEqual(0)
}

function testLogMethod(methodName: LogMapKeyType) {
  const logger = toMockLogger()
  logger[methodName]('eh')
  const set = logger.logMap.get(methodName)

  expect(set).toMatchSnapshot(methodName)

  // console.log(methodName, set, set.size)
  // @todo - is not working
  // expect(set.size).toEqual(0)
}

describe('logger', () => {
  it('should not have anything in it to begin', () => {
    const logger = toMockLogger()
    expectEmpty(logger)
  })
  it('should work for debug', () => {
    testLogMethod('debug')
  })
  it('should work for info', () => {
    testLogMethod('info')
  })
  it('should work for warn', () => {
    testLogMethod('warn')
  })
  it('should work for error', () => {
    testLogMethod('error')
  })
  it('should not leak', () => {
    const logger = toMockLogger()
    expectEmpty(logger)
  })
})