rewrite unit tests

This commit is contained in:
Nzix
2018-09-25 19:49:10 +08:00
parent a26ab583f3
commit 0d373be689
11 changed files with 123 additions and 165 deletions

View File

@ -84,34 +84,7 @@ function createWebAPIRequest(
});
}
function createRequest(path, method, data) {
return new Promise((resolve, reject) => {
const options = {
url: `http://music.163.com${path}`,
method: method,
headers: {
"Referer": "http://music.163.com",
"Cookie": "appver=1.5.2",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": randomUserAgent()
}
};
if (method.toLowerCase() === "post") {
options.body = data;
}
request(options, function(error, res, body) {
if (error) {
reject(error);
} else {
resolve(body);
}
});
});
}
module.exports = {
request,
createWebAPIRequest,
createRequest
createWebAPIRequest
};