mirror of
https://github.com/lyz05/danmaku.git
synced 2026-04-15 19:09:49 +08:00
142 lines
4.5 KiB
JavaScript
142 lines
4.5 KiB
JavaScript
let chai = require('chai');
|
|
let chaiHttp = require('chai-http');
|
|
let app = require('../app');
|
|
const { bilibili, mgtv, tencentvideo, youku, iqiyi } = require('../routes/api/base');
|
|
const list = [bilibili, mgtv, tencentvideo, youku, iqiyi];
|
|
|
|
let should = chai.should();
|
|
chai.use(chaiHttp);
|
|
|
|
describe('App', () => {
|
|
|
|
describe('弹幕解析模块测试', function () {
|
|
this.timeout(1000*10);
|
|
it('主页测试', (done) => {
|
|
chai.request(app)
|
|
.get('/')
|
|
.end((err, res) => {
|
|
res.should.have.status(200);
|
|
done();
|
|
});
|
|
});
|
|
|
|
for (const item of list) {
|
|
const name = item.name;
|
|
const example_urls = item.example_urls;
|
|
for (const i in example_urls) {
|
|
const url = example_urls[i];
|
|
it(name+'视频测试#'+i, (done) => {
|
|
chai.request(app)
|
|
.get('/')
|
|
.query({url})
|
|
.end((err, res) => {
|
|
res.should.have.status(200);
|
|
res.header['content-type'].should.equal('application/xml');
|
|
done();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
});
|
|
describe('users modules', () => {
|
|
it('should GET the users response', (done) => {
|
|
chai.request(app)
|
|
.get('/users')
|
|
.end((err, res) => {
|
|
res.should.have.status(200);
|
|
res.text.should.equal('respond with a resource');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should respond status 404', (done) => {
|
|
chai.request(app)
|
|
.get('/wrongUrl')
|
|
.end((err, res) => {
|
|
res.should.have.status(404);
|
|
done();
|
|
});
|
|
});
|
|
describe('ipinfo modules', () => {
|
|
it('GET the ipinfo response', (done) => {
|
|
chai.request(app)
|
|
.get('/ipinfo')
|
|
.end((err, res) => {
|
|
res.should.have.status(200);
|
|
done();
|
|
});
|
|
});
|
|
it('GET the ipinfo with name', (done) => {
|
|
chai.request(app)
|
|
.get('/ipinfo?name=home999.cc')
|
|
.end((err, res) => {
|
|
res.should.have.status(200);
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
describe('airportsub modules',function (){
|
|
this.timeout(1000*5);
|
|
it('接口不带参数测试', (done) =>{
|
|
chai.request(app)
|
|
.get('/sub')
|
|
.end((err,res) => {
|
|
res.should.have.status(400);
|
|
done();
|
|
});
|
|
});
|
|
it('接口错误参数测试', (done) =>{
|
|
chai.request(app)
|
|
.get('/sub?abc=123')
|
|
.end((err,res) => {
|
|
res.should.have.status(400);
|
|
done();
|
|
});
|
|
});
|
|
it('接口带user参数测试', (done) =>{
|
|
chai.request(app)
|
|
.get('/sub?user=congcong')
|
|
.end((err,res) => {
|
|
res.should.have.status(200);
|
|
done();
|
|
});
|
|
});
|
|
it('接口错误user参数测试', (done) =>{
|
|
chai.request(app)
|
|
.get('/sub?user=123')
|
|
.end((err,res) => {
|
|
res.should.have.status(404);
|
|
done();
|
|
});
|
|
});
|
|
it('接口带user与ctype参数测试', (done) =>{
|
|
chai.request(app)
|
|
.get('/sub?user=congcong&ctype=v2ray')
|
|
.end((err,res) => {
|
|
res.should.have.status(200);
|
|
done();
|
|
});
|
|
});
|
|
it('缓存测试', (done) =>{
|
|
chai.request(app)
|
|
.get('/sub/cache')
|
|
.end((err,res) => {
|
|
res.should.have.status(200);
|
|
done();
|
|
});
|
|
});
|
|
it('软件下载测试', (done) =>{
|
|
chai.request(app)
|
|
.get('/sub/download')
|
|
.end((err,res) => {
|
|
res.should.have.status(200);
|
|
res.text.should.have.string('clash');
|
|
res.text.should.have.string('v2ray');
|
|
res.text.should.have.string('shadowsocks');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
}); |