mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 21:28:06 +00:00
fix: add netease_api
This commit is contained in:
parent
fc0367c9b4
commit
0b701d23da
304 changed files with 27205 additions and 1 deletions
25
netease_api/test/album.test.js
Normal file
25
netease_api/test/album.test.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const assert = require('assert')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
describe('测试获取歌手专辑列表是否正常', () => {
|
||||
it('数据的 code 应该为200', (done) => {
|
||||
const qs = {
|
||||
id: 32311,
|
||||
}
|
||||
|
||||
axios
|
||||
.get(`${host}/album`, {
|
||||
params: qs,
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
if (status == 200) {
|
||||
assert(data.code === 200)
|
||||
}
|
||||
done()
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
25
netease_api/test/comment.test.js
Normal file
25
netease_api/test/comment.test.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const assert = require('assert')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
describe('测试获取评论是否正常', () => {
|
||||
it('数据的 code 应该为200', (done) => {
|
||||
const qs = {
|
||||
id: 32311,
|
||||
}
|
||||
|
||||
axios
|
||||
.get(`${host}/comment/album`, {
|
||||
params: qs,
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
if (status == 200) {
|
||||
assert(data.code === 200)
|
||||
}
|
||||
done()
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
32
netease_api/test/login.test.js
Normal file
32
netease_api/test/login.test.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
const assert = require('assert')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
console.log('注意: 测试登录需在 test/login.test.js 中填写账号密码!!!')
|
||||
const phone = ''
|
||||
const password = ''
|
||||
describe('测试登录是否正常', () => {
|
||||
it('手机登录 code 应该等于200', (done) => {
|
||||
const qs = {
|
||||
phone: process.env.NCM_API_TEST_LOGIN_PHONE || phone || '',
|
||||
password: process.env.NCM_API_TEST_LOGIN_PASSWORD || password || '',
|
||||
}
|
||||
|
||||
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('登录错误')
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
25
netease_api/test/lyric.test.js
Normal file
25
netease_api/test/lyric.test.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const assert = require('assert')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
describe('测试获取歌词是否正常', () => {
|
||||
it('数据应该有 lrc 字段', (done) => {
|
||||
const qs = {
|
||||
id: 347230,
|
||||
}
|
||||
|
||||
axios
|
||||
.get(`${host}/lyric`, {
|
||||
params: qs,
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
if (status == 200) {
|
||||
assert(typeof data.lrc !== 'undefined')
|
||||
}
|
||||
done()
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
26
netease_api/test/music_url.test.js
Normal file
26
netease_api/test/music_url.test.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const assert = require('assert')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
describe('测试获取歌曲是否正常', () => {
|
||||
it('歌曲的 url 不应该为空', (done) => {
|
||||
const qs = {
|
||||
id: 462791935,
|
||||
br: 999000,
|
||||
}
|
||||
|
||||
axios
|
||||
.get(`${host}/song/url`, {
|
||||
params: qs,
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
if (status == 200) {
|
||||
assert(!!data.data[0].url)
|
||||
}
|
||||
done()
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
25
netease_api/test/search.test.js
Normal file
25
netease_api/test/search.test.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const assert = require('assert')
|
||||
const axios = require('axios')
|
||||
const host = global.host || 'http://localhost:3000'
|
||||
|
||||
describe('测试搜索是否正常', () => {
|
||||
it('获取到的数据的 name 应该和搜索关键词一致', (done) => {
|
||||
const qs = {
|
||||
keywords: '海阔天空',
|
||||
type: 1,
|
||||
}
|
||||
axios
|
||||
.get(`${host}/search`, {
|
||||
params: qs,
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
if (status == 200) {
|
||||
assert(data.result.songs[0].name === '海阔天空')
|
||||
}
|
||||
done()
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue