From 2a366ef56dd1919143a3ed0d844b5045501ea737 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 27 Mar 2024 16:18:37 +0800 Subject: [PATCH] test: rss-parser test --- lib/setup.test.ts | 3 ++- lib/utils/rss-parser.test.ts | 16 ++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/setup.test.ts b/lib/setup.test.ts index 2946cdd13b..4e39c68dfa 100644 --- a/lib/setup.test.ts +++ b/lib/setup.test.ts @@ -66,7 +66,8 @@ const server = setupServer( return HttpResponse.json({ test: jsonData?.test, }); - }) + }), + http.get(`http://rsshub.test/rss`, () => HttpResponse.text('')) ); server.listen(); diff --git a/lib/utils/rss-parser.test.ts b/lib/utils/rss-parser.test.ts index 20b6664b56..0b09b61ea5 100644 --- a/lib/utils/rss-parser.test.ts +++ b/lib/utils/rss-parser.test.ts @@ -1,17 +1,9 @@ import { describe, expect, it } from 'vitest'; import parser from '@/utils/rss-parser'; -import { config } from '@/config'; -import nock from 'nock'; -describe('got', () => { - it('headers', async () => { - nock('http://rsshub.test') - .get('/test') - .reply(function () { - expect(this.req.headers['user-agent']).toBe(config.ua); - return [200, '']; - }); - - await parser.parseURL('http://rsshub.test/test'); +describe('rss-parser', () => { + it('rss', async () => { + const result = await parser.parseURL('http://rsshub.test/rss'); + expect(result).toBeTruthy(); }); });