Got unit tests passing again

This commit is contained in:
Chris Troutner
2021-08-08 08:09:48 -07:00
parent 0346898501
commit 758de6b088
7 changed files with 21 additions and 13 deletions
+2
View File
@@ -57,6 +57,8 @@ async function startServer () {
const controllers = new Controllers()
await controllers.attachControllers(app)
app.controllers = controllers
// Enable CORS for testing
// THIS IS A SECURITY RISK. COMMENT OUT FOR PRODUCTION
app.use(cors({ origin: '*' }))
+7 -3
View File
@@ -62,9 +62,9 @@ class IpfsAdapter {
// )
// Stop the IPFS node if we're running tests.
if (this.config.env === 'test') {
await this.ipfs.stop()
}
// if (this.config.env === 'test') {
// await this.ipfs.stop()
// }
// Signal that this adapter is ready.
this.isReady = true
@@ -75,6 +75,10 @@ class IpfsAdapter {
throw err
}
}
async stop () {
await this.ipfs.stop()
}
}
module.exports = IpfsAdapter
+2 -2
View File
@@ -38,13 +38,13 @@ class Controllers {
// Top-level function for this library.
// Start the various Controllers and attach them to the app.
attachRESTControllers (app) {
const rESTControllers = new RESTControllers({
const restControllers = new RESTControllers({
adapters: this.adapters,
useCases: this.useCases
})
// Attach the REST API Controllers associated with the boilerplate code to the Koa app.
rESTControllers.attachRESTControllers(app)
restControllers.attachRESTControllers(app)
}
// Add the JSON RPC router to the ipfs-coord adapter.
+3
View File
@@ -25,6 +25,9 @@ describe('Auth', () => {
// This should be the first instruction. It starts the REST API server.
await app.startServer()
// Stop the IPFS node for the rest of the e2e tests.
// await app.controllers.adapters.ipfs.stop()
// Delete all previous users in the database.
await testUtils.deleteAllUsers()
+2 -1
View File
@@ -12,7 +12,8 @@ const LOCALHOST = `http://localhost:${config.port}`
const context = {}
const UserController = require('../../../src/controllers/rest-api/users/controller')
const adapters = require('../../../src/adapters')
const Adapters = require('../../../src/adapters')
const adapters = new Adapters()
const UseCases = require('../../../src/use-cases/')
let uut
let sandbox
@@ -18,8 +18,8 @@ describe('#FullStackJWT', () => {
const localConfig = {
authServer: 'someserver',
apiServer: 'someserver',
login: 'somelogin',
password: 'somepassword'
fullstackLogin: 'somelogin',
fullstackPassword: 'somepassword'
}
uut = new FullStackJWT(localConfig)
})
@@ -81,7 +81,7 @@ describe('#FullStackJWT', () => {
const localConfig = {
authServer: 'someserver',
apiServer: 'someserver',
login: 'somelogin'
fullstackLogin: 'somelogin'
}
uut = new FullStackJWT(localConfig)
+2 -4
View File
@@ -6,8 +6,6 @@
// const assert = require('chai').assert
const sinon = require('sinon')
const adapters = require('../../../src/adapters')
// const { attachControllers } = require('../../../src/controllers')
const Controllers = require('../../../src/controllers')
describe('#Controllers', () => {
@@ -25,8 +23,8 @@ describe('#Controllers', () => {
describe('#attachControllers', () => {
it('should attach the controllers', async () => {
// mock IPFS
sandbox.stub(adapters.ipfs, 'start').resolves({})
adapters.ipfs.ipfsCoordAdapter = {
sandbox.stub(uut.adapters, 'start').resolves({})
uut.adapters.ipfs.ipfsCoordAdapter = {
attachRPCRouter: () => {}
}