remove double test with only a single change

This commit is contained in:
Einhornimmond 2023-07-06 08:28:27 +02:00
parent 213f1e1d3e
commit f403fc4192
3 changed files with 25 additions and 26 deletions

View File

@ -1,6 +1,29 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { IotaClientSingleton } from '@/client/IotaClientSingleton'
import CONFIG from '@/config'
import { logger } from '@/server/logger'
describe('apis/IotaClientSingleton/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/IotaClientSingleton/invalidIotaUrl', () => {
beforeEach(() => {
CONFIG.IOTA = true
CONFIG.IOTA_API_URL = 'invalidUrl'
})
it('throw exception on invalid iota url', () => {
// eslint-disable-next-line jest/unbound-method
expect(IotaClientSingleton.getInstance).toThrow()
})
})
describe('apis/IotaClientSingleton/enabled', () => {
describe('Hello World', () => {

View File

@ -34,8 +34,9 @@ class IotaClientSingleton {
return
}
if (!IotaClientSingleton.instance) {
const client = new ClientBuilder().node(CONFIG.IOTA_API_URL).build()
IotaClientSingleton.instance = new IotaClientSingleton()
IotaClientSingleton.instance.client = new ClientBuilder().node(CONFIG.IOTA_API_URL).build()
IotaClientSingleton.instance.client = client
}
return IotaClientSingleton.instance

View File

@ -1,25 +0,0 @@
import { IotaClientSingleton } from '@/client/IotaClientSingleton'
import CONFIG from '@/config'
import { logger } from '@/server/logger'
describe('apis/IotaClientSingleton/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/IotaClientSingleton/invalidIotaUrl', () => {
beforeEach(() => {
CONFIG.IOTA = true
CONFIG.IOTA_API_URL = 'invalidUrl'
})
it('throw exception on invalid iota url', () => {
// eslint-disable-next-line jest/unbound-method
expect(IotaClientSingleton.getInstance).toThrow()
})
})