diff --git a/.changeset/blue-birds-repeat.md b/.changeset/blue-birds-repeat.md new file mode 100644 index 0000000..248d8f9 --- /dev/null +++ b/.changeset/blue-birds-repeat.md @@ -0,0 +1,5 @@ +--- +'prettier-plugin-astro': patch +--- + +Fix test macro 'PrettierMarkdown' diff --git a/test/astro-prettier.test.mjs b/test/astro-prettier.test.mjs index c394641..b0ae34b 100644 --- a/test/astro-prettier.test.mjs +++ b/test/astro-prettier.test.mjs @@ -28,13 +28,13 @@ const getMarkdownFiles = async (name) => { */ const Prettier = async (t, name) => { const [src, out] = await getFiles(name); - t.not(src, out); + t.not(src, out, 'Unformated file and formated file are the same'); const formatted = format(src); - t.is(formatted, out); + t.is(formatted, out, 'Incorrect formating'); // test that our formatting is idempotent const formattedTwice = format(formatted); - t.is(formatted, formattedTwice); + t.is(formatted, formattedTwice, 'Formatting is not idempotent'); }; /** @@ -50,26 +50,26 @@ Prettier.title = (title, name) => `${title}: const PrettierUnaltered = async (t, name) => { const [src, out] = await getFiles(name); - t.is(src, out); // the output should be unchanged + t.is(src, out, 'Unformated file and formated file are not the same'); // the output should be unchanged const formatted = format(src); - t.is(formatted, out); + t.is(formatted, out, 'Incorrect formating'); // test that our formatting is idempotent const formattedTwice = format(formatted); - t.is(formatted, formattedTwice); + t.is(formatted, formattedTwice, 'Formatting is not idempotent'); }; PrettierUnaltered.title = Prettier.title; const PrettierMarkdown = async (t, name) => { const [src, out] = await getMarkdownFiles(name); - t.not(src, out); + t.not(src, out, 'Unformated file and formated file are the same'); const formatted = markdownFormat(src); - t.not(formatted, out); + t.is(formatted, out, 'Incorrect formating'); // test that our formatting is idempotent const formattedTwice = markdownFormat(formatted); - t.is(formatted, formattedTwice); + t.is(formatted, formattedTwice, 'Formatting is not idempotent'); }; PrettierMarkdown.title = (title, name) => `${title}: diff --git a/test/fixtures/out/embedded-in-markdown.md b/test/fixtures/out/embedded-in-markdown.md index 0d5a65c..ab3f33b 100644 --- a/test/fixtures/out/embedded-in-markdown.md +++ b/test/fixtures/out/embedded-in-markdown.md @@ -54,13 +54,9 @@ For best results, you should only have one ` + - - ... - + ... ``` @@ -123,7 +119,6 @@ Astro components can define local variables inside of the Frontmatter script. An --- const name = "Your name here"; --- -

Hello {name}!

@@ -149,7 +144,6 @@ const name = "Your name here"; --- const items = ["Dog", "Cat", "Platipus"]; --- - @@ -182,9 +176,8 @@ export interface Props { } const { greeting = "Hello", name } = Astro.props; --- -
-

{greeting}, {name}!

+

{greeting}, {name}!

``` @@ -195,7 +188,8 @@ const { greeting = "Hello", name } = Astro.props; ```astro
- + +
@@ -255,9 +249,9 @@ An Astro component template can render as many top-level elements as you'd like. ```astro -
-
-
+
+
+
``` When working inside a JSX expression, however, you must wrap multiple elements inside of a **Fragment**. Fragments let you render a set of elements without adding extra nodes to the DOM. This is required in JSX expressions because of a limitation of JavaScript: You can never `return` more than one thing in a JavaScript function or expression. Using a Fragment solves this problem. @@ -268,7 +262,6 @@ A Fragment must open with `<>` and close with ``. Don't worry if you forget t --- const items = ["Dog", "Cat", "Platipus"]; --- -
    {items.map((item) => <>
  • Red {item}
  • @@ -326,7 +319,6 @@ The recommended approach is to place files within `public/*`. This references a // ✅ Correct: references src/thumbnail.png import thumbnailSrc from "./thumbnail.png"; --- - ```