gradido/backend/src/apis/IotaConnector_disabled.test.ts
2023-06-18 17:58:12 +02:00

27 lines
882 B
TypeScript

import { IotaClientSingleton } from '@/apis/IotaConnector'
import { CONFIG } from '@/config'
import { backendLogger as logger } from '@/server/logger'
describe('apis/IotaConnector/disabled', () => {
beforeEach(() => {
CONFIG.IOTA = false
})
it('getInstance return undefined if iota is disabled', () => {
const spyLog = jest.spyOn(logger, 'info')
expect(IotaClientSingleton.getInstance()).toBeUndefined()
expect(spyLog).toHaveBeenCalledWith('Iota are disabled via config...')
})
})
describe('apis/IotaConnector/invalidIotaUrl', () => {
beforeEach(() => {
CONFIG.IOTA = true
CONFIG.IOTA_API_URL = 'invalidUrl'
})
it('log "couldn\'t connect to iota"', () => {
const spyLog = jest.spyOn(logger, 'error')
expect(IotaClientSingleton.getInstance()).toBeUndefined()
expect(spyLog).toHaveBeenCalledWith("couldn't connect to iota")
})
})