Skip to content

Commit

Permalink
修复测试不通过的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed May 30, 2022
1 parent b3ca432 commit 47bd917
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions beforeTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const generateConfig = require('./generateConfig')
generateConfig()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
"test": "mocha -r intelli-espower-loader -t 20000 server.test.js main.test.js --exit",
"test": "node beforeTest.js && mocha -r intelli-espower-loader -t 30000 server.test.js main.test.js --exit",
"lint": "eslint \"**/*.{js,ts}\"",
"lint-fix": "eslint --fix \"**/*.{js,ts}\"",
"prepare": "husky install",
Expand Down
3 changes: 2 additions & 1 deletion test/album.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const assert = require('assert')
const axios = require('axios')
const host = global.host || 'http://localhost:3000'

const config = require('../util/config.json')
describe('测试获取歌手专辑列表是否正常', () => {
it('数据的 code 应该为200', (done) => {
const qs = {
id: 32311,
cookie: config.anonymous_token,
}

axios
Expand Down
3 changes: 2 additions & 1 deletion test/comment.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const assert = require('assert')
const axios = require('axios')
const host = global.host || 'http://localhost:3000'

const config = require('../util/config.json')
describe('测试获取评论是否正常', () => {
it('数据的 code 应该为200', (done) => {
const qs = {
id: 32311,
cookie: config.anonymous_token,
}

axios
Expand Down
3 changes: 2 additions & 1 deletion test/lyric.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const assert = require('assert')
const axios = require('axios')
const host = global.host || 'http://localhost:3000'

const config = require('../util/config.json')
describe('测试获取歌词是否正常', () => {
it('数据应该有 lrc 字段', (done) => {
const qs = {
id: 347230,
cookie: config.anonymous_token,
}

axios
Expand Down
3 changes: 2 additions & 1 deletion test/music_url.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const assert = require('assert')
const axios = require('axios')
const host = global.host || 'http://localhost:3000'

const config = require('../util/config.json')
describe('测试获取歌曲是否正常', () => {
it('歌曲的 url 不应该为空', (done) => {
const qs = {
id: 462791935,
br: 999000,
realIP: '116.25.146.177',
cookie: config.anonymous_token,
}

axios
Expand Down
3 changes: 2 additions & 1 deletion test/search.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const assert = require('assert')
const axios = require('axios')
const host = global.host || 'http://localhost:3000'

const config = require('../util/config.json')
describe('测试搜索是否正常', () => {
it('获取到的数据的 name 应该和搜索关键词一致', (done) => {
const qs = {
keywords: '海阔天空',
type: 1,
cookie: config.anonymous_token,
}
axios
.get(`${host}/search`, {
Expand Down
5 changes: 3 additions & 2 deletions util/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ "anonymous_token": "登录网易云音乐网页版,此字段值替换为cookie中MUSIC_U对应的值",
{
"anonymous_token": "bf8bfeabb1aa84f9c8c3906c04a04fb864322804c83f5d607e91a04eae463c9436bd1a17ec353cf742a0e13bf4a3d0575ac3ffbf24b9c165993166e004087dd3a20e6c18bed612c072ea5b4f70e962ab276621b2ff13050f1471df55ea867f53807e650dd04abd3fb8130b7ae43fcc5b",
"resourceTypeMap": {
"0": "R_SO_4_",
"1": "R_MV_5_",
Expand All @@ -8,4 +9,4 @@
"5": "R_VI_62_",
"6": "A_EV_2_"
}
}
}

0 comments on commit 47bd917

Please sign in to comment.