docfast/src/__tests__/examples-url-to-pdf.test.ts
Hoid c233f289c9
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
feat: add URL-to-PDF examples to examples page
- Add 'URL to PDF' nav link and example section
- Show basic and advanced cURL examples for /v1/convert/url
- Include security notes (JS disabled, private URLs blocked)
- Add test coverage for the new section
2026-03-05 17:03:23 +01:00

35 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { readFileSync } from 'fs';
import { join } from 'path';
describe('examples.html - URL to PDF section', () => {
const html = readFileSync(join(__dirname, '../../public/examples.html'), 'utf-8');
it('contains a URL to PDF section', () => {
expect(html).toContain('id="url-to-pdf"');
expect(html).toContain('URL to PDF');
});
it('contains a nav link to the URL to PDF section', () => {
expect(html).toContain('href="#url-to-pdf"');
});
it('uses the correct API URL (docfast.dev, not api.docfast.dev)', () => {
expect(html).toContain('https://docfast.dev/v1/convert/url');
expect(html).not.toContain('api.docfast.dev');
});
it('shows the /v1/convert/url endpoint', () => {
expect(html).toContain('/v1/convert/url');
});
it('does NOT reference non-existent SDKs for URL conversion', () => {
expect(html).not.toContain('docfast-url');
expect(html).not.toContain('url-to-pdf-sdk');
});
it('mentions security notes about JavaScript and private URLs', () => {
expect(html).toMatch(/[Jj]ava[Ss]cript.*disabled|disabled.*[Jj]ava[Ss]cript/i);
expect(html).toMatch(/private|internal/i);
});
});