summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Caleb Jasik <calebjasik@jasik.xyz> 2021-06-25 17:21:03 -0500
committerGravatar GitHub <noreply@github.com> 2021-06-25 15:21:03 -0700
commit05d6fc66bba277af4324ce6ac0d4647239cce247 (patch)
treee0c3c97c279282187fa9f6e476b5490e03242788
parent8aca0fabaf2fef3f3986fa3b18ccb8aeab80c325 (diff)
downloadastro-05d6fc66bba277af4324ce6ac0d4647239cce247.tar.gz
astro-05d6fc66bba277af4324ce6ac0d4647239cce247.tar.zst
astro-05d6fc66bba277af4324ce6ac0d4647239cce247.zip
prettier-plugin: Add a test for JSX embedded in an attribute. This test currently fails. (#508)
* Add a test for JSX embedded in an attribute. This test currently fails. * Oops forgot the semicolons on the correct output * Add `--scope prettier-plugin-astro` so that the prettier plugin is tested on default CI * Replace `assert.equal` with `assert.fixture` to remain inline w/ main * Update astro-prettier.test.js * Skip the other failing test. Co-authored-by: Fred K. Schott <fkschott@gmail.com>
-rw-r--r--package.json2
-rw-r--r--tools/prettier-plugin-astro/test/astro-prettier.test.js11
-rw-r--r--tools/prettier-plugin-astro/test/fixtures/in/attribute-with-embedded-expr.astro6
-rw-r--r--tools/prettier-plugin-astro/test/fixtures/out/attribute-with-embedded-expr.astro6
4 files changed, 23 insertions, 2 deletions
diff --git a/package.json b/package.json
index c19e80a6f..a7d08b0d9 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"dev:vscode": "lerna run dev --scope astro-languageserver --scope astro-vscode --scope @astrojs/parser --parallel --stream",
"format": "prettier -w \"**/*.{js,jsx,ts,tsx,md,json}\"",
"lint": "eslint \"packages/**/*.ts\"",
- "test": "lerna run test --scope astro --stream",
+ "test": "lerna run test --scope astro --scope prettier-plugin-astro --stream",
"test:core": "yarn workspace astro run test",
"test:templates": "lerna run test --scope create-astro --stream"
},
diff --git a/tools/prettier-plugin-astro/test/astro-prettier.test.js b/tools/prettier-plugin-astro/test/astro-prettier.test.js
index 19ce12a22..bc86ab1b1 100644
--- a/tools/prettier-plugin-astro/test/astro-prettier.test.js
+++ b/tools/prettier-plugin-astro/test/astro-prettier.test.js
@@ -33,7 +33,7 @@ Prettier('can format an Astro file with frontmatter', async () => {
assert.fixture(formatted, out);
});
-Prettier('can format an Astro file with embedded JSX expressions', async () => {
+Prettier.skip('can format an Astro file with embedded JSX expressions', async () => {
const [src, out] = await getFiles('embedded-expr');
assert.not.fixture(src, out);
@@ -41,4 +41,13 @@ Prettier('can format an Astro file with embedded JSX expressions', async () => {
assert.fixture(formatted, out);
});
+// This is currently failing! See: https://github.com/snowpackjs/astro/issues/478
+Prettier.skip('can format an Astro file with a JSX expression in an attribute', async () => {
+ const [src, out] = await getFiles('attribute-with-embedded-expr');
+ assert.not.fixture(src, out);
+
+ const formatted = format(src);
+ assert.fixture(formatted, out);
+});
+
Prettier.run();
diff --git a/tools/prettier-plugin-astro/test/fixtures/in/attribute-with-embedded-expr.astro b/tools/prettier-plugin-astro/test/fixtures/in/attribute-with-embedded-expr.astro
new file mode 100644
index 000000000..e393b531d
--- /dev/null
+++ b/tools/prettier-plugin-astro/test/fixtures/in/attribute-with-embedded-expr.astro
@@ -0,0 +1,6 @@
+---
+export let post
+export let author
+---
+
+ <a class="author" href={`/author/${post.author}`}>{author.name}</a> \ No newline at end of file
diff --git a/tools/prettier-plugin-astro/test/fixtures/out/attribute-with-embedded-expr.astro b/tools/prettier-plugin-astro/test/fixtures/out/attribute-with-embedded-expr.astro
new file mode 100644
index 000000000..d7050eb8d
--- /dev/null
+++ b/tools/prettier-plugin-astro/test/fixtures/out/attribute-with-embedded-expr.astro
@@ -0,0 +1,6 @@
+---
+export let post;
+export let author;
+---
+
+<a class="author" href={`/author/${post.author}`}>{author.name}</a>