mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-consumer.git
synced 2026-09-21 16:52:03 -07:00
Got existing unit tests passing
This commit is contained in:
@@ -8,6 +8,7 @@ const sinon = require('sinon')
|
||||
const IPFSCoordAdapter = require('../../../src/adapters/ipfs/ipfs-coord')
|
||||
const IPFSMock = require('../mocks/ipfs-mock')
|
||||
const IPFSCoordMock = require('../mocks/ipfs-coord-mock')
|
||||
const EventEmitter = require('events')
|
||||
|
||||
describe('#IPFS', () => {
|
||||
let uut
|
||||
@@ -15,7 +16,7 @@ describe('#IPFS', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
const ipfs = IPFSMock.create()
|
||||
uut = new IPFSCoordAdapter({ ipfs })
|
||||
uut = new IPFSCoordAdapter({ ipfs, eventEmitter: new EventEmitter() })
|
||||
|
||||
sandbox = sinon.createSandbox()
|
||||
})
|
||||
|
||||
@@ -8,13 +8,14 @@ const sinon = require('sinon')
|
||||
const IPFSLib = require('../../../src/adapters/ipfs')
|
||||
const IPFSMock = require('../mocks/ipfs-mock')
|
||||
const IPFSCoordMock = require('../mocks/ipfs-coord-mock')
|
||||
const EventEmitter = require('events')
|
||||
|
||||
describe('#IPFS-adapter-index', () => {
|
||||
let uut
|
||||
let sandbox
|
||||
|
||||
beforeEach(() => {
|
||||
uut = new IPFSLib()
|
||||
uut = new IPFSLib({ eventEmitter: new EventEmitter() })
|
||||
|
||||
sandbox = sinon.createSandbox()
|
||||
})
|
||||
|
||||
@@ -74,10 +74,17 @@ describe('#JSON RPC', () => {
|
||||
})
|
||||
|
||||
it('should return default response if routing is not possible', async () => {
|
||||
// Force desired code path
|
||||
// sandbox
|
||||
// .stub(uut.adapters.ipfs.ipfsCoordAdapter, 'peerInputHandler')
|
||||
// .returns()
|
||||
// uut.adapters.ipfs.ipfsCoordAdapter.peer
|
||||
|
||||
const id = uid()
|
||||
const json = jsonrpc.request(id, 'unknownMethod', {})
|
||||
|
||||
const str = JSON.stringify(json)
|
||||
// console.log(`str: ${str}`)
|
||||
|
||||
const result = await uut.router(str, 'peerA')
|
||||
// console.log('result: ', result)
|
||||
@@ -204,7 +211,9 @@ describe('#JSON RPC', () => {
|
||||
// Force the RPC type to be 'success', to indicate an RPC that was
|
||||
// processed internal to ipfs-coord.
|
||||
sandbox.stub(uut.jsonrpc, 'parse').returns({
|
||||
payload: {},
|
||||
payload: {
|
||||
id: 'metrics5323'
|
||||
},
|
||||
type: 'success'
|
||||
})
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ const ipfs = {
|
||||
sendPrivateMessage: () => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
peerInputHandler: () => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Public npm libraries
|
||||
const assert = require('chai').assert
|
||||
const sinon = require('sinon')
|
||||
const EventEmitter = require('events')
|
||||
|
||||
// Local support libraries
|
||||
// const testUtils = require('../../utils/test-utils')
|
||||
@@ -25,7 +26,7 @@ describe('#use-cases', () => {
|
||||
beforeEach(() => {
|
||||
sandbox = sinon.createSandbox()
|
||||
|
||||
uut = new UseCases({ adapters })
|
||||
uut = new UseCases({ adapters, eventEmitter: new EventEmitter() })
|
||||
})
|
||||
|
||||
afterEach(() => sandbox.restore())
|
||||
|
||||
Reference in New Issue
Block a user