Path: blob/main/tests/unit/yaml-intelligence/hover-info.test.ts
6451 views
/*1* hover-info.test.ts2*3* Copyright (C) 2022 Posit Software, PBC4*5*/6import { assert } from "testing/asserts";78import {9createVirtualDocument,10hover,11} from "../../../src/core/lib/yaml-intelligence/hover.ts";12import { yamlValidationUnitTest } from "../schema-validation/utils.ts";13import { getYamlIntelligenceResource } from "../../../src/core/lib/yaml-intelligence/resources.ts";14import { YamlIntelligenceContext } from "../../../src/core/lib/yaml-intelligence/types.ts";1516const source = `---17title: foo18echo: false19---20Here's some text.2122\`\`\`{python}23#| echo: true24#| code-fold: true25# and some python26import time27print(time.time())28\`\`\`29`;3031const context: YamlIntelligenceContext = {32code: source,33position: { row: 8, column: 3 },34engine: "knitr",35project_formats: [],36formats: ["html"],37path: null,38filetype: "markdown",39embedded: false,40line: "",41};4243yamlValidationUnitTest("createVirtualDocument - simple()", async () => {44const result = await createVirtualDocument(context);45assert(result.doc.length === source.length);46});4748yamlValidationUnitTest("hover-info - simple()", async () => {49const result = await hover(context);5051const hoverInfo = `**code-fold**\n\n${52// deno-lint-ignore no-explicit-any53(getYamlIntelligenceResource("schema/cell-codeoutput.yml") as any)[2]54.description.long55}`;56assert(57result !== null &&58result.content === hoverInfo,59);60});616263