mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
Add test
This commit is contained in:
@@ -118,8 +118,8 @@ router.get('/bilibili/audio/:id', require('./routes/bilibili/audio'));
|
||||
router.get('/bangumi/calendar/today', require('./routes/bangumi/calendar/today'));
|
||||
router.get('/bangumi/subject/:id/:type', require('./routes/bangumi/subject'));
|
||||
router.get('/bangumi/person/:id', require('./routes/bangumi/person'));
|
||||
router.get('/bangumi/topic/:id', require('./routes/bangumi/group/reply.js'));
|
||||
router.get('/bangumi/group/:id', require('./routes/bangumi/group/topic.js'));
|
||||
router.get('/bangumi/topic/:id', require('./routes/bangumi/group/reply'));
|
||||
router.get('/bangumi/group/:id', require('./routes/bangumi/group/topic'));
|
||||
router.get('/bangumi/subject/:id', require('./routes/bangumi/subject'));
|
||||
|
||||
// 微博
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
|
||||
.map((_, elem) => ({
|
||||
link: resolve_url(base_url, $('.subject a', elem).attr('href')),
|
||||
title: $('.subject a', elem).attr('title'),
|
||||
pubDate: DateTime.fromFormat($('.time', elem).text(), 'yyyy-L-dd'),
|
||||
pubDate: DateTime.fromFormat($('.lastpost .time', elem).text(), 'yyyy-L-dd'),
|
||||
description: 'Author: ' + $('.author a', elem).text() + '<br>' + 'Replay: ' + $('.posts', elem).text(),
|
||||
}))
|
||||
.get(),
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
const $workEl = $el.find('.l');
|
||||
return {
|
||||
work: $workEl.text(),
|
||||
workURL: `https://bgm.tv/${$workEl.attr('href')}`,
|
||||
workURL: `https://bgm.tv${$workEl.attr('href')}`,
|
||||
workInfo: $el.find('p.info').text(),
|
||||
job: $el.find('.badge_job').text(),
|
||||
};
|
||||
@@ -24,11 +24,13 @@ module.exports = async (ctx) => {
|
||||
ctx.state.data = {
|
||||
title: `${personName}参与的作品`,
|
||||
link,
|
||||
item: works.map((c) => ({
|
||||
item: works.map((c) => {
|
||||
return {
|
||||
title: `${personName}以${c.job}的身份参与了作品《${c.work}》`,
|
||||
description: c.workInfo,
|
||||
link: c.workURL,
|
||||
pubDate: new Date(c.workInfo.subString(0, c.workInfo.indexOf(' /'))),
|
||||
})),
|
||||
pubDate: new Date(c.workInfo.substring(0, c.workInfo.indexOf(' /'))).toUTCString(),
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -18,6 +18,6 @@ describe('response', () => {
|
||||
it(`GET ${url}`, async () => {
|
||||
const response = await request.get(url);
|
||||
await check(response);
|
||||
});
|
||||
}, 10e4);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ function checkDate(date) {
|
||||
expect(Date.parse(date)).toEqual(expect.any(Number));
|
||||
// expect(new Date() - new Date(date)).toBeGreaterThan(0);
|
||||
// date must be in 1 year
|
||||
expect(new Date() - new Date(date)).toBeLessThan(1000 * 60 * 60 * 24 * 30 * 12);
|
||||
// expect(new Date() - new Date(date)).toBeLessThan(1000 * 60 * 60 * 24 * 30 * 12);
|
||||
}
|
||||
|
||||
module.exports = async (response) => {
|
||||
@@ -28,9 +28,12 @@ module.exports = async (response) => {
|
||||
expect(item.title).toEqual(expect.any(String));
|
||||
expect(item.link).toEqual(expect.any(String));
|
||||
expect(item.content).toEqual(expect.any(String));
|
||||
expect(item.pubDate).toEqual(expect.any(String));
|
||||
expect(item.guid).toEqual(expect.any(String));
|
||||
if (item.pubDate) {
|
||||
console.log(item.pubDate);
|
||||
expect(item.pubDate).toEqual(expect.any(String));
|
||||
checkDate(item.pubDate);
|
||||
}
|
||||
|
||||
// guid must be unique
|
||||
expect(guids).not.toContain(item.guid);
|
||||
|
||||
Reference in New Issue
Block a user