Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/unit/yaml-intelligence/hover-info.test.ts
6451 views
1
/*
2
* hover-info.test.ts
3
*
4
* Copyright (C) 2022 Posit Software, PBC
5
*
6
*/
7
import { assert } from "testing/asserts";
8
9
import {
10
createVirtualDocument,
11
hover,
12
} from "../../../src/core/lib/yaml-intelligence/hover.ts";
13
import { yamlValidationUnitTest } from "../schema-validation/utils.ts";
14
import { getYamlIntelligenceResource } from "../../../src/core/lib/yaml-intelligence/resources.ts";
15
import { YamlIntelligenceContext } from "../../../src/core/lib/yaml-intelligence/types.ts";
16
17
const source = `---
18
title: foo
19
echo: false
20
---
21
Here's some text.
22
23
\`\`\`{python}
24
#| echo: true
25
#| code-fold: true
26
# and some python
27
import time
28
print(time.time())
29
\`\`\`
30
`;
31
32
const context: YamlIntelligenceContext = {
33
code: source,
34
position: { row: 8, column: 3 },
35
engine: "knitr",
36
project_formats: [],
37
formats: ["html"],
38
path: null,
39
filetype: "markdown",
40
embedded: false,
41
line: "",
42
};
43
44
yamlValidationUnitTest("createVirtualDocument - simple()", async () => {
45
const result = await createVirtualDocument(context);
46
assert(result.doc.length === source.length);
47
});
48
49
yamlValidationUnitTest("hover-info - simple()", async () => {
50
const result = await hover(context);
51
52
const hoverInfo = `**code-fold**\n\n${
53
// deno-lint-ignore no-explicit-any
54
(getYamlIntelligenceResource("schema/cell-codeoutput.yml") as any)[2]
55
.description.long
56
}`;
57
assert(
58
result !== null &&
59
result.content === hoverInfo,
60
);
61
});
62
63