36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
import { describe, test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { resolveWeasyprint as resolvePdf } from '../build-pdf.mjs';
|
|
import { resolveWeasyprint as resolveCarousel } from '../build-carousel.mjs';
|
|
|
|
// S1 (correction #3): when weasyprint is not resolvable on PATH, the degradation
|
|
// helper must return a skip-signal (NOT throw) and emit an install hint, so the
|
|
// render scripts can skip the PDF step gracefully instead of crashing.
|
|
|
|
for (const [name, resolveWeasyprint] of [
|
|
['build-pdf', resolvePdf],
|
|
['build-carousel', resolveCarousel],
|
|
]) {
|
|
describe(`resolveWeasyprint — ${name}`, () => {
|
|
test('returns a skip-signal (not a throw) when weasyprint is absent', () => {
|
|
let result;
|
|
assert.doesNotThrow(() => {
|
|
result = resolveWeasyprint(() => false);
|
|
});
|
|
assert.equal(result.available, false);
|
|
});
|
|
|
|
test('emits an install hint when absent', () => {
|
|
const result = resolveWeasyprint(() => false);
|
|
assert.ok(typeof result.hint === 'string' && result.hint.length > 0);
|
|
assert.match(result.hint, /weasyprint/i);
|
|
assert.match(result.hint, /install/i);
|
|
});
|
|
|
|
test('reports available when the probe succeeds', () => {
|
|
const result = resolveWeasyprint(() => true);
|
|
assert.equal(result.available, true);
|
|
assert.equal(result.hint, undefined);
|
|
});
|
|
});
|
|
}
|