|
| 1 | +/* |
| 2 | + * single-file-engine-resolution.test.ts |
| 3 | + * |
| 4 | + * Tests that singleFileProjectContext resolves engine extensions |
| 5 | + * even without renderOptions (the preview code path). |
| 6 | + * Related to issue #13983 |
| 7 | + * |
| 8 | + * Copyright (C) 2026 Posit Software, PBC |
| 9 | + */ |
| 10 | + |
| 11 | +import { unitTest } from "../../test.ts"; |
| 12 | +import { assert } from "testing/asserts"; |
| 13 | +import { join } from "../../../src/deno_ral/path.ts"; |
| 14 | +import { singleFileProjectContext } from "../../../src/project/types/single-file/single-file.ts"; |
| 15 | +import { notebookContext } from "../../../src/render/notebook/notebook-context.ts"; |
| 16 | +import { initYamlIntelligenceResourcesFromFilesystem } from "../../../src/core/schema/utils.ts"; |
| 17 | + |
| 18 | +unitTest( |
| 19 | + "singleFileProjectContext resolves engine extensions without renderOptions", |
| 20 | + async () => { |
| 21 | + await initYamlIntelligenceResourcesFromFilesystem(); |
| 22 | + |
| 23 | + const tmpDir = Deno.makeTempDirSync({ prefix: "quarto-test" }); |
| 24 | + const file = join(tmpDir, "test.qmd"); |
| 25 | + Deno.writeTextFileSync( |
| 26 | + file, |
| 27 | + "---\ntitle: test\nengine: julia\n---\n", |
| 28 | + ); |
| 29 | + |
| 30 | + try { |
| 31 | + const nbContext = notebookContext(); |
| 32 | + const project = await singleFileProjectContext(file, nbContext); |
| 33 | + |
| 34 | + assert( |
| 35 | + project.config !== undefined, |
| 36 | + "config should be initialized even without renderOptions", |
| 37 | + ); |
| 38 | + assert( |
| 39 | + Array.isArray(project.config?.engines) && |
| 40 | + project.config.engines.length > 0, |
| 41 | + "engine extensions should be resolved (bundled engines discovered)", |
| 42 | + ); |
| 43 | + } finally { |
| 44 | + Deno.removeSync(tmpDir, { recursive: true }); |
| 45 | + } |
| 46 | + }, |
| 47 | +); |
0 commit comments