重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
const assert = require('assert')
|
||||
const Module = require('module')
|
||||
|
||||
const calls = []
|
||||
const originalLoad = Module._load
|
||||
|
||||
Module._load = function mockRequestModule(request, parent, isMain) {
|
||||
if (request === '../utils/request') {
|
||||
return options => {
|
||||
calls.push(options)
|
||||
return Promise.resolve(options)
|
||||
}
|
||||
}
|
||||
return originalLoad.apply(this, arguments)
|
||||
}
|
||||
|
||||
const paymentApi = require('./payment')
|
||||
const afterSaleApi = require('./after-sale')
|
||||
const growthApi = require('./growth')
|
||||
|
||||
paymentApi.prepareOrderPayment(12)
|
||||
paymentApi.mockOrderPaymentSuccess(12)
|
||||
afterSaleApi.applyAfterSale({ orderId: 12, reason: 'need refund' })
|
||||
afterSaleApi.getMyAfterSales({ page: 2, size: 5 })
|
||||
growthApi.getGrowthSummary()
|
||||
|
||||
Module._load = originalLoad
|
||||
|
||||
assert.deepStrictEqual(calls[0], {
|
||||
url: '/payment/order/12/prepare',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
})
|
||||
assert.deepStrictEqual(calls[1], {
|
||||
url: '/payment/order/12/mock-success',
|
||||
method: 'POST',
|
||||
data: {}
|
||||
})
|
||||
assert.deepStrictEqual(calls[2], {
|
||||
url: '/after-sale/apply',
|
||||
method: 'POST',
|
||||
data: { orderId: 12, reason: 'need refund' }
|
||||
})
|
||||
assert.deepStrictEqual(calls[3], {
|
||||
url: '/after-sale/my',
|
||||
params: { page: 2, size: 5 }
|
||||
})
|
||||
assert.deepStrictEqual(calls[4], {
|
||||
url: '/growth/summary'
|
||||
})
|
||||
Reference in New Issue
Block a user