Files
ipfs-bch-wallet-consumer/test/unit/use-cases/index.use-case.unit.js
T

67 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-11-23 08:38:01 -08:00
/*
Unit tests for the index.js file that aggregates all use-cases.
*/
// Public npm libraries
2022-09-08 08:58:39 -07:00
import { assert } from 'chai'
import sinon from 'sinon'
import EventEmitter from 'events'
2021-11-23 08:38:01 -08:00
// Local support libraries
// const testUtils = require('../../utils/test-utils')
// Unit under test (uut)
2022-09-08 08:58:39 -07:00
import UseCases from '../../../src/use-cases/index.js'
import adapters from '../mocks/adapters/index.js'
2021-11-23 08:38:01 -08:00
describe('#use-cases', () => {
let uut
let sandbox
before(async () => {
// Delete all previous users in the database.
// await testUtils.deleteAllUsers()
})
beforeEach(() => {
sandbox = sinon.createSandbox()
2021-11-26 13:17:16 -08:00
uut = new UseCases({ adapters, eventEmitter: new EventEmitter() })
2021-11-23 08:38:01 -08:00
})
afterEach(() => sandbox.restore())
describe('#constructor', () => {
it('should throw an error if adapters are not passed in', () => {
try {
uut = new UseCases()
assert.fail('Unexpected code path')
// This is here to prevent the linter from complaining.
assert.isOk(uut)
} catch (err) {
assert.include(
err.message,
'Instance of adapters must be passed in when instantiating Use Cases library.'
)
}
})
})
2022-06-27 10:15:35 -07:00
describe('#start', () => {
it('should initialize async use cases', async () => {
const result = await uut.start()
assert.equal(result, true)
})
// it('should catch and throw errors', async () => {
// // Force an error
// sandbox.stub()
// })
})
2021-11-23 08:38:01 -08:00
})