29 lines
841 B
TypeScript
29 lines
841 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { enrichLink } from '../src/enrichment/enricher.js';
|
|
|
|
describe('enrichment', () => {
|
|
it('marks dead, paywall, and unreachable links', async () => {
|
|
await expect(
|
|
enrichLink('https://x.test/dead', async () => ({
|
|
status: 404,
|
|
finalUrl: 'https://x.test/dead',
|
|
html: ''
|
|
}))
|
|
).resolves.toMatchObject({
|
|
status: 'dead'
|
|
});
|
|
await expect(
|
|
enrichLink('https://x.test/a', async () => ({
|
|
status: 200,
|
|
finalUrl: 'https://x.test/login',
|
|
html: '<title>Login</title>'
|
|
}))
|
|
).resolves.toMatchObject({ status: 'paywall' });
|
|
await expect(
|
|
enrichLink('https://x.test/a', async () => Promise.reject(new Error('timeout')))
|
|
).resolves.toMatchObject({
|
|
status: 'unreachable'
|
|
});
|
|
});
|
|
});
|