mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-22 15:41:23 +08:00
test: use axios
This commit is contained in:
+14
-12
@@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const request = require('request')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
console.log('注意: 测试登录需在 test/login.test.js 中填写账号密码!!!')
|
||||
@@ -12,18 +12,20 @@ describe('测试登录是否正常', () => {
|
||||
password: process.env.NCM_API_TEST_LOGIN_PASSWORD || password || '',
|
||||
}
|
||||
|
||||
request.get(
|
||||
{ url: `${host}/login/cellphone`, qs: qs },
|
||||
(err, res, body) => {
|
||||
if (!err && res.statusCode == 200) {
|
||||
body = JSON.parse(body)
|
||||
assert(body.code === 200)
|
||||
console.log('昵称:' + body.profile.nickname)
|
||||
axios
|
||||
.get(`${host}/login/cellphone`, {
|
||||
params: qs,
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
if (status == 200) {
|
||||
console.log('昵称:' + data.profile.nickname)
|
||||
assert(data.code === 200)
|
||||
done()
|
||||
} else {
|
||||
done('登录错误')
|
||||
}
|
||||
},
|
||||
)
|
||||
done('登录错误')
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user