mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-21 16:52:00 -07:00
feat(order/offer): Refactored code to switch Order and Offer terminology
This commit is contained in:
@@ -64,53 +64,36 @@ describe('#Order-REST-Router', () => {
|
||||
describe('#createOrder', () => {
|
||||
it('should create a new order', async () => {
|
||||
ctx.request.body = {
|
||||
appId: 'swapTest555',
|
||||
data: {
|
||||
messageType: 1,
|
||||
messageClass: 1,
|
||||
tokenId:
|
||||
'38e97c5d7d3585a2cbf3f9580c82ca33985f9cb0845d4dcce220cb709f9538b0',
|
||||
buyOrSell: 'sell',
|
||||
rateInSats: 1000,
|
||||
minSatsToExchange: 10,
|
||||
numTokens: 0.02,
|
||||
utxoTxid:
|
||||
'241c06bf61384b8623477e419bf4779edbcc7e3bc862f0f179a9ed2967069b87',
|
||||
utxoVout: 0
|
||||
},
|
||||
timestamp: '2021-09-20T17:54:26.395Z',
|
||||
localTimeStamp: '9/20/2021, 10:54:26 AM',
|
||||
txid: '46f50f2a0cf44e3ed70dfb0618ef3ebfee57aabcf229b5d2d17c07322b54a8d7',
|
||||
hash: 'zdpuB2X25AZCKo3wpr4sSbw44vqPWJRqcxWQRHZccK5BdtoGD'
|
||||
order: {}
|
||||
}
|
||||
|
||||
// Mock dependencies
|
||||
// sandbox.stub(uut.useCases.order, 'createOrder').resolves()
|
||||
sandbox.stub(uut.useCases.order, 'createOrder').resolves('testHash')
|
||||
|
||||
await uut.createOrder(ctx)
|
||||
|
||||
// assert.equal(ctx.body.hash, 'testHash')
|
||||
assert.equal(ctx.body.hash, 'testHash')
|
||||
})
|
||||
|
||||
// it('should catch and throw an error', async () => {
|
||||
// try {
|
||||
// ctx.request.body = {
|
||||
// order: {}
|
||||
// }
|
||||
//
|
||||
// // Force an error
|
||||
// sandbox
|
||||
// .stub(uut.useCases.order, 'createOrder')
|
||||
// .rejects(new Error('test error'))
|
||||
//
|
||||
// await uut.createOrder(ctx)
|
||||
//
|
||||
// assert.fail('Unexpected code path')
|
||||
// } catch (err) {
|
||||
// // console.log('err: ', err)
|
||||
// assert.include(err.message, 'test error')
|
||||
// }
|
||||
// })
|
||||
it('should catch and throw an error', async () => {
|
||||
try {
|
||||
ctx.request.body = {
|
||||
order: {}
|
||||
}
|
||||
|
||||
// Force an error
|
||||
sandbox
|
||||
.stub(uut.useCases.order, 'createOrder')
|
||||
.rejects(new Error('test error'))
|
||||
|
||||
await uut.createOrder(ctx)
|
||||
|
||||
assert.fail('Unexpected code path')
|
||||
} catch (err) {
|
||||
// console.log('err: ', err)
|
||||
assert.include(err.message, 'test error')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('#handleError', () => {
|
||||
|
||||
Reference in New Issue
Block a user