2021-07-11 21:59:18 -07:00
|
|
|
/*
|
|
|
|
|
Unit tests for controllers index.js file.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Public npm libraries
|
|
|
|
|
// const assert = require('chai').assert
|
2022-09-08 08:58:39 -07:00
|
|
|
import sinon from 'sinon'
|
2021-07-11 21:59:18 -07:00
|
|
|
|
2022-09-08 08:58:39 -07:00
|
|
|
import Controllers from '../../../src/controllers/index.js'
|
2021-07-11 21:59:18 -07:00
|
|
|
|
|
|
|
|
describe('#Controllers', () => {
|
2021-07-25 16:49:01 -07:00
|
|
|
let uut
|
2021-07-11 21:59:18 -07:00
|
|
|
let sandbox
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
sandbox = sinon.createSandbox()
|
2021-07-25 16:49:01 -07:00
|
|
|
|
|
|
|
|
uut = new Controllers()
|
2021-07-11 21:59:18 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
afterEach(() => sandbox.restore())
|
|
|
|
|
|
|
|
|
|
describe('#attachControllers', () => {
|
|
|
|
|
it('should attach the controllers', async () => {
|
|
|
|
|
// mock IPFS
|
2021-08-08 08:09:48 -07:00
|
|
|
sandbox.stub(uut.adapters, 'start').resolves({})
|
|
|
|
|
uut.adapters.ipfs.ipfsCoordAdapter = {
|
2021-07-11 21:59:18 -07:00
|
|
|
attachRPCRouter: () => {}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 06:09:56 -08:00
|
|
|
// Mock the timer controllers
|
|
|
|
|
sandbox.stub(uut.timerControllers, 'startTimers').returns()
|
|
|
|
|
|
2021-07-11 21:59:18 -07:00
|
|
|
const app = {
|
|
|
|
|
use: () => {}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-25 16:49:01 -07:00
|
|
|
await uut.attachControllers(app)
|
2021-07-11 21:59:18 -07:00
|
|
|
})
|
|
|
|
|
})
|
2025-06-27 20:11:27 -04:00
|
|
|
describe('#attachRESTControllers', () => {
|
|
|
|
|
it('should attach the controllers', async () => {
|
|
|
|
|
const app = {
|
|
|
|
|
use: () => {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await uut.attachRESTControllers(app)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
describe('#initAdapters', () => {
|
|
|
|
|
it('should attach the controllers', async () => {
|
|
|
|
|
sandbox.stub(uut.adapters, 'start').resolves({})
|
|
|
|
|
await uut.initAdapters()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
describe('#initUseCases', () => {
|
|
|
|
|
it('should attach the controllers', async () => {
|
|
|
|
|
sandbox.stub(uut.useCases, 'start').resolves({})
|
|
|
|
|
await uut.initUseCases()
|
|
|
|
|
})
|
|
|
|
|
})
|
2021-07-11 21:59:18 -07:00
|
|
|
})
|