Skip to content

Commit 93b1d49

Browse files
committed
test: create normalizeYamlSyntax tests
1 parent a346218 commit 93b1d49

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/utils/tests/parser.test.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
parseYAMLIntoMetadata,
66
transformTypeToReferenceLink,
77
parseHeadingIntoMetadata,
8+
normalizeYamlSyntax,
89
} from '../parser/index.mjs';
910

1011
describe('transformTypeToReferenceLink', () => {
@@ -23,6 +24,35 @@ describe('transformTypeToReferenceLink', () => {
2324
});
2425
});
2526

27+
describe('normalizeYamlSyntax', () => {
28+
it('should normalize YAML syntax by fixing noncompliant properties', () => {
29+
const input = `introduced_in=v0.1.21
30+
source_link=lib/test.js
31+
type=module
32+
name=test_module
33+
llm_description=This is a test module`;
34+
35+
const normalizedYaml = normalizeYamlSyntax(input);
36+
37+
strictEqual(
38+
normalizedYaml,
39+
`introduced_in: v0.1.21
40+
source_link: lib/test.js
41+
type: module
42+
name: test_module
43+
llm_description: This is a test module`
44+
);
45+
});
46+
47+
it('should remove leading and trailing newlines', () => {
48+
const input = '\nintroduced_in=v0.1.21\n';
49+
50+
const normalizedYaml = normalizeYamlSyntax(input);
51+
52+
strictEqual(normalizedYaml, 'introduced_in: v0.1.21');
53+
});
54+
});
55+
2656
describe('parseYAMLIntoMetadata', () => {
2757
it('should parse a YAML string into a JavaScript object', () => {
2858
const input = 'name: test\ntype: module\nintroduced_in: v1.0.0';

0 commit comments

Comments
 (0)