Browse Source

add frontmatter test

nHigashiWeseek 1 year ago
parent
commit
76137f4e93
1 changed files with 19 additions and 0 deletions
  1. 19 0
      packages/markdown-splitter/test/index.spec.ts

+ 19 - 0
packages/markdown-splitter/test/index.spec.ts

@@ -268,6 +268,25 @@ Content under header 2.
       { label: '2-content', text: 'Content under header 2.' },
       { label: '2-content', text: 'Content under header 2.' },
     ];
     ];
 
 
+    const result = await splitMarkdownIntoChunks(markdown);
+    expect(result).toEqual(expected);
+  });
+  test('frontmatter is processed and labeled correctly', async() => {
+    const markdown = `---
+title: Test Document
+author: John Doe
+---
+
+# Header 1
+Some introductory content.
+    `;
+
+    const expected: Chunk[] = [
+      { label: 'frontmatter', text: JSON.stringify({ title: 'Test Document', author: 'John Doe' }, null, 2) },
+      { label: '1-heading', text: '# Header 1' },
+      { label: '1-content', text: 'Some introductory content.' },
+    ];
+
     const result = await splitMarkdownIntoChunks(markdown);
     const result = await splitMarkdownIntoChunks(markdown);
     expect(result).toEqual(expected);
     expect(result).toEqual(expected);
   });
   });