From 9b79f1a132d27e5c906122381b998ba909903877 Mon Sep 17 00:00:00 2001 From: Archie Wood <58074498+archiewood@users.noreply.github.com> Date: Tue, 21 Jan 2025 14:40:32 -0500 Subject: [PATCH] basic unit test --- .../preprocess/src/add-blank-lines.spec.cjs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 packages/lib/preprocess/src/add-blank-lines.spec.cjs diff --git a/packages/lib/preprocess/src/add-blank-lines.spec.cjs b/packages/lib/preprocess/src/add-blank-lines.spec.cjs new file mode 100644 index 0000000000..9b17fa4436 --- /dev/null +++ b/packages/lib/preprocess/src/add-blank-lines.spec.cjs @@ -0,0 +1,47 @@ +import { describe, it, expect } from 'vitest'; +import addBlankLines from '../src/add-blank-lines.cjs'; + +describe('addBlankLines Preprocessor', () => { + it('should not add blank lines to standard markdown', () => { + const input = `# Hello, world! +This is a test.`; + const expectedOutput = `# Hello, world! +This is a test.`; + + const result = addBlankLines.markup({ content: input, filename: 'test.md' }); + + expect(result.code).toBe(expectedOutput); + }); + + it('should add blank lines before and after each block content', () => { + const input = `# Hello, world! +This is a test. +\`\`\`sql orders +SELECT * FROM orders +\`\`\` + +{#each orders as order} +1. {order.name} +{/each} +`; + const expectedOutput = `# Hello, world! +This is a test. +\`\`\`sql orders +SELECT * FROM orders +\`\`\` + +{#each orders as order} + +1. {order.name} + +{/each} +`; + + const result = addBlankLines.markup({ content: input, filename: 'test.md' }); + + console.log(input); + console.log(result.code); + + expect(result.code).toBe(expectedOutput); + }); +});