Files
RSSHub/lib/app.test.ts
T
Tony 7ab0d1eff4 fix(ua): ensure header-generator and custom ua are effective with each other (#21546)
* fix(ua): ensure header-generator and custom ua are effective with each other

* fix(ua): review comment
2026-03-29 22:47:56 +08:00

24 lines
675 B
TypeScript

import undici from 'undici';
import { describe, expect, it, vi } from 'vitest';
import app from '@/app';
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')).toMatch(/Chrome/);
});
});