Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
test(rome_js_formatter): Add prettier JSX tests
Browse files Browse the repository at this point in the history
This PR extracts the JSX tests from prettier and updates existing tests.

There are a few instability issues, most related to comments. I'll look into those as part of the comments refactoring
  • Loading branch information
MichaReiser committed Sep 19, 2022
1 parent 9c35299 commit 380a55b
Show file tree
Hide file tree
Showing 60 changed files with 2,893 additions and 186 deletions.
2 changes: 1 addition & 1 deletion crates/rome_js_formatter/tests/prettier_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct TestInfo {

mod check_reformat;

tests_macros::gen_tests! {"tests/specs/prettier/{js,typescript}/**/*.{js,ts,jsx,tsx}", crate::test_snapshot, "script"}
tests_macros::gen_tests! {"tests/specs/prettier/{js,typescript,jsx}/**/*.{js,ts,jsx,tsx}", crate::test_snapshot, "script"}

const PRETTIER_IGNORE: &str = "prettier-ignore";
const ROME_IGNORE: &str = "rome-ignore format: prettier ignore";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export {
// a
foo1,

// b
bar1,
baz1,
Expand All @@ -14,7 +13,6 @@ const baz2 = 1;
export {
// a
foo2,

// b
bar2,
baz2,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,3 @@ if (
) {
a;
}

if (
// comment
1
) {
b;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
source: crates/rome_js_formatter/tests/prettier_tests.rs
info:
test_file: js/if/trailing_comment.js
---

# Input
Expand All @@ -17,13 +19,6 @@ if (
) {
a;
}

if (
// comment
1
) {
b;
}
```


Expand All @@ -42,17 +37,6 @@ if (
}
if (code === 92) {
/* '\' */
@@ -16,3 +15,10 @@
) {
a;
}
+
+if (
+ // comment
+ 1
+) {
+ b;
+}
```

# Output
Expand All @@ -75,13 +59,6 @@ if (
) {
a;
}

if (
// comment
1
) {
b;
}
```


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { foo2 } from "foo.json" assert { type: "json" };
export { default as foo2 } from "foo.json" assert { type: "json" };
export * from "foo.json" assert { type: "json" };
export * as foo3 from "foo.json" assert { type: "json" };
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { foo2 } from "foo.json" assert { type: "json" };
export { default as foo2 } from "foo.json" assert { type: "json" };
export * from "foo.json" assert { type: "json" };
export * as foo3 from "foo.json" assert { type: "json" };
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ const taskLater = #{ ...taskNow, status: "DONE" }

// A reminder: The ordering of keys in record literals does not affect equality (and is not retained)
assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 })

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
source: crates/rome_js_formatter/tests/prettier_tests.rs
info:
test_file: js/record/spread.js
---

# Input
Expand All @@ -11,7 +13,6 @@ const taskLater = #{ ...taskNow, status: "DONE" }

// A reminder: The ordering of keys in record literals does not affect equality (and is not retained)
assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 })

```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,43 +85,75 @@ skip(`does something really long and complicated so I have to write a very long

skip("does something really long and complicated so I have to write a very long name for the test", () => {});

test.step("does something really long and complicated so I have to write a very long name for the test", () => {});
test.step(
"does something really long and complicated so I have to write a very long name for the test",
() => {},
);

test.step(`does something really long and complicated so I have to write a very long name for the test`, () => {});
test.step(
`does something really long and complicated so I have to write a very long name for the test`,
() => {},
);

test.describe("does something really long and complicated so I have to write a very long name for the test", () => {});
test.describe(
"does something really long and complicated so I have to write a very long name for the test",
() => {},
);

test.describe(`does something really long and complicated so I have to write a very long name for the test`, () => {});
test.describe(
`does something really long and complicated so I have to write a very long name for the test`,
() => {},
);

test.describe
.only("does something really long and complicated so I have to write a very long name for the test", () => {});
test.describe.only(
"does something really long and complicated so I have to write a very long name for the test",
() => {},
);

test.describe
.only(`does something really long and complicated so I have to write a very long name for the test`, () => {});
test.describe.only(
`does something really long and complicated so I have to write a very long name for the test`,
() => {},
);

test.describe
.parallel("does something really long and complicated so I have to write a very long name for the test", () => {});
test.describe.parallel(
"does something really long and complicated so I have to write a very long name for the test",
() => {},
);

test.describe
.parallel(`does something really long and complicated so I have to write a very long name for the test`, () => {});
test.describe.parallel(
`does something really long and complicated so I have to write a very long name for the test`,
() => {},
);

test.describe.parallel
.only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {});
test.describe.parallel.only(
"does something really long and complicated so I have to write a very long name for the testThis is a very",
() => {},
);

test.describe.parallel
.only(`does something really long and complicated so I have to write a very long name for the testThis is a very`, () => {});
test.describe.parallel.only(
`does something really long and complicated so I have to write a very long name for the testThis is a very`,
() => {},
);

test.describe
.serial("does something really long and complicated so I have to write a very long name for the test", () => {});
test.describe.serial(
"does something really long and complicated so I have to write a very long name for the test",
() => {},
);

test.describe
.serial(`does something really long and complicated so I have to write a very long name for the test`, () => {});
test.describe.serial(
`does something really long and complicated so I have to write a very long name for the test`,
() => {},
);

test.describe.serial
.only("does something really long and complicated so I have to write a very long name for the test", () => {});
test.describe.serial.only(
"does something really long and complicated so I have to write a very long name for the test",
() => {},
);

test.describe.serial
.only(`does something really long and complicated so I have to write a very long name for the test`, () => {});
test.describe.serial.only(
`does something really long and complicated so I have to write a very long name for the test`,
() => {},
);

// Should break

Expand Down
Loading

0 comments on commit 380a55b

Please sign in to comment.