mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
test: filter_time
This commit is contained in:
@@ -9,10 +9,6 @@ module.exports = async (ctx, next) => {
|
|||||||
'Content-Type': 'text/html; charset=UTF-8',
|
'Content-Type': 'text/html; charset=UTF-8',
|
||||||
});
|
});
|
||||||
ctx.body = `RSSHub 发生了一些意外: <pre>${err instanceof Error ? err.stack : err}</pre>`;
|
ctx.body = `RSSHub 发生了一些意外: <pre>${err instanceof Error ? err.stack : err}</pre>`;
|
||||||
if (err.status === 401) {
|
ctx.status = 404;
|
||||||
ctx.status = 401;
|
|
||||||
} else {
|
|
||||||
ctx.status = 404;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
|||||||
item.push({
|
item.push({
|
||||||
title: `Title${i}`,
|
title: `Title${i}`,
|
||||||
description: `Description${i}`,
|
description: `Description${i}`,
|
||||||
pubDate: new Date(`2018-4-${i}`).toUTCString(),
|
pubDate: new Date(new Date() - i * 10 * 1000).toUTCString(),
|
||||||
link: `https://github.com/DIYgod/RSSHub/issues/${i}`,
|
link: `https://github.com/DIYgod/RSSHub/issues/${i}`,
|
||||||
author: `DIYgod${i}`,
|
author: `DIYgod${i}`,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ describe('filter', () => {
|
|||||||
expect(parsed.items[1].title).toBe('Title5');
|
expect(parsed.items[1].title).toBe('Title5');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`filter_time`, async () => {
|
||||||
|
const response = await request.get('/test/1?filter_time=25');
|
||||||
|
const parsed = await parser.parseString(response.text);
|
||||||
|
expect(parsed.items.length).toBe(2);
|
||||||
|
expect(parsed.items[0].title).toBe('Title1');
|
||||||
|
expect(parsed.items[1].title).toBe('Title2');
|
||||||
|
});
|
||||||
|
|
||||||
it(`filterout`, async () => {
|
it(`filterout`, async () => {
|
||||||
const response = await request.get('/test/1?filterout=Description4|Title5');
|
const response = await request.get('/test/1?filterout=Description4|Title5');
|
||||||
const parsed = await parser.parseString(response.text);
|
const parsed = await parser.parseString(response.text);
|
||||||
|
|||||||
Reference in New Issue
Block a user