mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 14:41:23 +08:00
test: use axios
This commit is contained in:
+12
-8
@@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const request = require('request')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
describe('测试获取歌曲是否正常', () => {
|
||||
@@ -9,14 +9,18 @@ describe('测试获取歌曲是否正常', () => {
|
||||
br: 999000,
|
||||
}
|
||||
|
||||
request.get({ url: `${host}/song/url`, qs: qs }, (err, res, body) => {
|
||||
if (!err && res.statusCode == 200) {
|
||||
body = JSON.parse(body)
|
||||
assert(!!body.data[0].url)
|
||||
axios
|
||||
.get(`${host}/song/url`, {
|
||||
params: qs,
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
if (status == 200) {
|
||||
assert(!!data.data[0].url)
|
||||
}
|
||||
done()
|
||||
} else {
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user