| 123456789101112131415161718192021222324 |
- import { DirectFetchAdapter } from '../src//infrastructure/adapters/direct-fetch.adapter';
- describe('DirectFetchAdapter', () => {
- let adapter: DirectFetchAdapter;
- beforeEach(() => {
- adapter = new DirectFetchAdapter();
- });
- it('fetches HTML from a valid URL', async () => {
- const html = await adapter.fetch('https://httpbin.org/html');
- expect(html).toContain('<html>');
- });
- it('throws on non-200 response', async () => {
- await expect(adapter.fetch('https://httpbin.org/status/404')).rejects.toThrow();
- });
- it('throws on non-HTML content type', async () => {
- await expect(adapter.fetch('https://httpbin.org/json')).rejects.toThrow(
- 'non-HTML'
- );
- });
- });
|