diff options
| author | Asko Nõmm <asko@nmm.ee> | 2025-01-25 22:12:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-25 22:12:30 +0200 |
| commit | 160cb5a7c2a733ee9c1eaa69008148ba9c21125d (patch) | |
| tree | 7d5649d027444443e4aedda7293627d37d956d00 /src/flatmatter.test.ts | |
| parent | 7f3a7e9770623743fde1cc9fde8aea7d476a5700 (diff) | |
| parent | d8d3118a9bdfe822292d1f4d28d2879aaa1ae86f (diff) | |
Merge pull request #3 from askonomm/2-if-the-content-starts-and-ends-with-----add-content-item-frontmatter
Implement FrontMatter parsing.
Diffstat (limited to 'src/flatmatter.test.ts')
| -rw-r--r-- | src/flatmatter.test.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/flatmatter.test.ts b/src/flatmatter.test.ts index 4c349aa..bbe26d9 100644 --- a/src/flatmatter.test.ts +++ b/src/flatmatter.test.ts @@ -1,16 +1,22 @@ -import FlatMatter from "./flatmatter"; +import FlatMatter from "./flatmatter.ts"; import {assert} from "vitest"; +import ToObject from "./serializers/to_object.ts"; test('Line has no value separator', () => { - expect(() => new FlatMatter('test')) - .toThrowError("Line on index 0 doesn't have a value separator."); + assert.throws(() => new FlatMatter('test'), "Line on index 0 doesn't have a value separator."); }) test('Line can only have one value separator', () => { - expect(() => new FlatMatter('test: this: that')) - .toThrowError("Line on index 0 has multiple value separators.") + assert.throws(() => new FlatMatter('test: this: that'), 'Line on index 0 has multiple value separators.') }) test('String values can have colon characters', () => { assert.doesNotThrow(() => new FlatMatter('test: "this : that"'), Error) +}) + +test('FrontMatter creates a new content entry', () => { + const fm = new FlatMatter(`---\nthis: true\n---\n\nMarkdown goes here.\n\nAnd here.`); + const result = fm.serialize(new ToObject()); + + assert.deepEqual(result, {"this": true, "content": "Markdown goes here.\n\nAnd here."}); })
\ No newline at end of file |
