Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding aditional tests just to make sure frontmatter #294

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions test/content-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,16 @@ date: "2024-08-30"
# Markdown Content Here
`;

export const markdownWithFrontMatterAndAdditional = `
---
title: "Sample Title"
date: "2024-08-30"
---

# Markdown Content Here

---

This is additional content.
`;

10 changes: 9 additions & 1 deletion test/writr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from 'vitest';
import {Writr} from '../src/writr.js';
import {
productPageWithMarkdown, blogPostWithMarkdown, projectDocumentationWithMarkdown, markdownWithFrontMatter,
productPageWithMarkdown, blogPostWithMarkdown, projectDocumentationWithMarkdown, markdownWithFrontMatter, markdownWithFrontMatterAndAdditional,
} from './content-fixtures.js';

describe('writr', () => {
Expand Down Expand Up @@ -271,6 +271,14 @@ describe('WritrFrontMatter', () => {
expect(frontMatter).to.haveOwnProperty('title', 'Project Documentation');
});

test('should return the front matter as an object with additional properties', () => {
const writr = new Writr(markdownWithFrontMatterAndAdditional);
expect(writr.frontMatter).to.haveOwnProperty('title', 'Sample Title');
expect(writr.frontMatter).to.haveOwnProperty('date', '2024-08-30');
expect(writr.content).to.contain('---');
expect(writr.content).to.contain('This is additional content.');
});

test('should set the front matter', () => {
const writr = new Writr(projectDocumentationWithMarkdown);
const meta = writr.frontMatter;
Expand Down
Loading