Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/unit/yaml-intelligence/error-colon-no-space.test.ts
6452 views
1
/*
2
* error-colon-no-space.test.ts
3
*
4
* Copyright (C) 2022 Posit Software, PBC
5
*
6
*/
7
8
import { asMappedString } from "../../../src/core/mapped-text.ts";
9
import {
10
readAndValidateYamlFromMappedString,
11
ValidationError,
12
} from "../../../src/core/lib/yaml-schema/validated-yaml.ts";
13
14
import {
15
assertYamlValidationFails,
16
expectValidationError,
17
schemaFromString,
18
yamlValidationUnitTest,
19
} from "../schema-validation/utils.ts";
20
21
yamlValidationUnitTest("error-colon-no-space", async () => {
22
const schema = schemaFromString(`
23
id: schema-test-1
24
record:
25
baz: number
26
bar: string
27
`);
28
const ymlStr = `
29
title:Test
30
`;
31
await assertYamlValidationFails(async () => {
32
const { yamlValidationErrors } = await readAndValidateYamlFromMappedString(
33
asMappedString(ymlStr),
34
schema,
35
);
36
throw new ValidationError("this should throw", yamlValidationErrors);
37
}, (e) =>
38
expectValidationError(e)
39
.toHaveLength(1)
40
.forSchemaPathToEndWith(["object", "type"])
41
.toHaveInfo("suggestion-fix"));
42
});
43
44