mirror of
https://github.com/ant-design/ant-design-cli.git
synced 2026-09-14 19:07:15 +08:00
35 lines
931 B
TypeScript
35 lines
931 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { parseFrontMatter } from './frontMatter.js';
|
|
|
|
describe('parseFrontMatter', () => {
|
|
it('does not treat indented delimiter text as the closing delimiter', () => {
|
|
const parsed = parseFrontMatter(`---
|
|
title: Example
|
|
description: |
|
|
---
|
|
nested text
|
|
---
|
|
Body`);
|
|
|
|
expect(parsed.data).toEqual({
|
|
title: 'Example',
|
|
description: '---\nnested text\n',
|
|
});
|
|
expect(parsed.content).toBe('Body');
|
|
});
|
|
|
|
it('parses front matter after a leading UTF-8 BOM', () => {
|
|
const parsed = parseFrontMatter('\uFEFF---\ntitle: Example\n---\nBody');
|
|
|
|
expect(parsed.data).toEqual({ title: 'Example' });
|
|
expect(parsed.content).toBe('Body');
|
|
});
|
|
|
|
it('strips a leading UTF-8 BOM when no front matter exists', () => {
|
|
const parsed = parseFrontMatter('\uFEFFBody');
|
|
|
|
expect(parsed.data).toEqual({});
|
|
expect(parsed.content).toBe('Body');
|
|
});
|
|
});
|