This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const assert = require('assert')
|
||||
|
||||
global.API_DOMAIN = 'http://127.0.0.1/api'
|
||||
global.REQUEST_TIMEOUT = 1000
|
||||
global.ENABLE_REQUEST_SIGNING = false
|
||||
|
||||
let uploadOptions
|
||||
global.wx = {
|
||||
getStorageSync: () => ({}),
|
||||
uploadFile(options) {
|
||||
uploadOptions = options
|
||||
options.success({
|
||||
statusCode: 200,
|
||||
data: '{"code":200,"data":{"fileId":9223372036854775001,"id":9223372036854775002}}'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const { uploadFile } = require('./upload')
|
||||
|
||||
async function run() {
|
||||
const result = await uploadFile({
|
||||
url: '/user/workbench/register/avatar',
|
||||
filePath: '/tmp/avatar.png',
|
||||
name: 'file',
|
||||
formData: { registrationTicket: 'ticket' }
|
||||
})
|
||||
|
||||
assert.strictEqual(uploadOptions.url, 'http://127.0.0.1:80/api/user/workbench/register/avatar')
|
||||
assert.strictEqual(result.fileId, '9223372036854775001')
|
||||
assert.strictEqual(result.id, '9223372036854775002')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
Reference in New Issue
Block a user