direct-fetch.adapter.spec.ts 703 B

123456789101112131415161718192021222324
  1. import { DirectFetchAdapter } from '../src//infrastructure/adapters/direct-fetch.adapter';
  2. describe('DirectFetchAdapter', () => {
  3. let adapter: DirectFetchAdapter;
  4. beforeEach(() => {
  5. adapter = new DirectFetchAdapter();
  6. });
  7. it('fetches HTML from a valid URL', async () => {
  8. const html = await adapter.fetch('https://httpbin.org/html');
  9. expect(html).toContain('<html>');
  10. });
  11. it('throws on non-200 response', async () => {
  12. await expect(adapter.fetch('https://httpbin.org/status/404')).rejects.toThrow();
  13. });
  14. it('throws on non-HTML content type', async () => {
  15. await expect(adapter.fetch('https://httpbin.org/json')).rejects.toThrow(
  16. 'non-HTML'
  17. );
  18. });
  19. });