mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-03-13 10:30:18 +08:00
26 lines
719 B
TypeScript
26 lines
719 B
TypeScript
import undici from 'undici';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import app from '@/app';
|
|
|
|
const { config } = await import('@/config');
|
|
|
|
describe('index', () => {
|
|
it('serve index', async () => {
|
|
const res = await app.request('/');
|
|
expect(res.status).toBe(200);
|
|
expect(await res.text()).toContain('Welcome to RSSHub!');
|
|
});
|
|
});
|
|
|
|
describe('request-rewriter', () => {
|
|
it('should rewrite request', async () => {
|
|
const fetchSpy = vi.spyOn(undici, 'fetch');
|
|
await app.request('/test/httperror');
|
|
|
|
// headers
|
|
const headers: Headers = fetchSpy.mock.lastCall?.[0].headers;
|
|
expect(headers.get('user-agent')).toBe(config.ua);
|
|
});
|
|
});
|