test: use axios

This commit is contained in:
YXL
2020-10-01 23:23:18 +08:00
parent cea2024288
commit 57e5e0f5e5
7 changed files with 74 additions and 54 deletions
+12 -8
View File
@@ -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)
}
})
})
})
})