Skip to content

Commit

Permalink
Merge pull request #33 from eric2788/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eric2788 authored Nov 11, 2022
2 parents d835fe1 + 8da5087 commit 1139e57
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ const api = axios.create({
}
})

const antiCrawler = axios.create({
headers: {}
})

describe('B站API測試', () => {
it('測試用戶ID是否存在', async () => {
const res = await api.get('https://api.bilibili.com/x/space/acc/info?mid=1&jsonp=jsonp')
Expand All @@ -23,11 +19,13 @@ describe('B站API測試', () => {
assert.equal(res.data.code, -404)
})
it('測試B站反爬蟲', async () => {
const res = await antiCrawler.get('https://api.bilibili.com/x/space/acc/info?mid=1&jsonp=jsonp')
const res = await api.get('https://api.bilibili.com/x/space/acc/info?mid=1&jsonp=jsonp', {
headers: {}
})
console.log(res.data)
assert.equal(res.status, 200)
assert.equal(res.data.code, -401)
assert.notEqual(res.data?.data?.ga_data, undefined)
// 有时候没有设置 user-agent 也能正常返回消息,因此无法测试
// assert.equal(res.data.code, -401)
})
it('測試房間ID是否存在', async () => {
const res = await api.get('https://api.live.bilibili.com/room/v1/Room/room_init?id=1')
Expand Down

0 comments on commit 1139e57

Please sign in to comment.