Skip to content

Commit a0daa6a

Browse files
committed
test(formatter): Fix tests using TS syntax with .js
1 parent 229b2be commit a0daa6a

File tree

6 files changed

+184
-28
lines changed

6 files changed

+184
-28
lines changed

crates/oxc_formatter/tests/fixtures/js/comments/assignments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const jestPackageJson =
1515
class A {
1616
#testerConfig;
1717
constructor() {
18-
let basePath: string | undefined =
18+
let basePath =
1919
this.#testerConfig.languageOptions.parserOptions?.tsconfigRootDir;
2020
}
2121
}

crates/oxc_formatter/tests/fixtures/js/comments/assignments.js.snap

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,33 @@ const jestPackageJson =
1919
class A {
2020
#testerConfig;
2121
constructor() {
22-
let basePath: string | undefined =
22+
let basePath =
2323
this.#testerConfig.languageOptions.parserOptions?.tsconfigRootDir;
2424
}
2525
}
2626

2727
==================== Output ====================
28+
var longlonglonglonglonglong =
29+
/*#__PURE__*/ _interopDefaultLegacy(aaaaaaaaaaaaaaa);
30+
var short = /*#__PURE__*/ _interopDefaultLegacy(b);
31+
32+
const jestPackageJson =
33+
// eslint-disable-next-line @typescript-eslint/no-require-imports
34+
require(jestPath);
35+
36+
{
37+
sourcemap =
38+
/** @type {'inline' | 'hidden' | 'sourcemap'} */ (
39+
process.env.WORKER_MODE
40+
) || sourcemap;
41+
}
42+
43+
class A {
44+
#testerConfig;
45+
constructor() {
46+
let basePath =
47+
this.#testerConfig.languageOptions.parserOptions?.tsconfigRootDir;
48+
}
49+
}
2850

2951
===================== End =====================
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
11
function *t1() {
22
yield (
33
// comment
4-
a as any
4+
a
55
);
66
}
77
function *t2() {
88
yield (
99
// comment
10-
a as any
10+
a
1111
) + 1;
1212
}
1313
function *t3() {
1414
yield (
1515
// comment
16-
a as any
16+
a
1717
) ? 0 : 1;
1818
}
1919
function *t4() {
2020
yield (
2121
// comment
22-
a as any
22+
a
2323
).b;
2424
}
2525
function *t5() {
2626
yield (
2727
// comment
28-
a as any
28+
a
2929
)[a];
3030
}
3131
function *t6() {
3232
yield (
3333
// comment
34-
a as any
34+
a
3535
)();
3636
}
3737
function *t7() {
3838
yield (
3939
// comment
40-
a as any
40+
a
4141
)``;
4242
}
4343
function *t8() {
4444
yield (
4545
// comment
46-
a as any
47-
) as any;
46+
a
47+
);
4848
}
4949
function *t9() {
5050
yield (
5151
// comment
52-
a as any
53-
) satisfies any;
52+
a
53+
);
5454
}
5555
function *t10() {
5656
yield (
5757
// comment
58-
a as any
59-
)!;
58+
a
59+
);
6060
}

crates/oxc_formatter/tests/fixtures/js/comments/yield.js.snap

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,126 @@ source: crates/oxc_formatter/tests/fixtures/mod.rs
55
function *t1() {
66
yield (
77
// comment
8-
a as any
8+
a
99
);
1010
}
1111
function *t2() {
1212
yield (
1313
// comment
14-
a as any
14+
a
1515
) + 1;
1616
}
1717
function *t3() {
1818
yield (
1919
// comment
20-
a as any
20+
a
2121
) ? 0 : 1;
2222
}
2323
function *t4() {
2424
yield (
2525
// comment
26-
a as any
26+
a
2727
).b;
2828
}
2929
function *t5() {
3030
yield (
3131
// comment
32-
a as any
32+
a
3333
)[a];
3434
}
3535
function *t6() {
3636
yield (
3737
// comment
38-
a as any
38+
a
3939
)();
4040
}
4141
function *t7() {
4242
yield (
4343
// comment
44-
a as any
44+
a
4545
)``;
4646
}
4747
function *t8() {
4848
yield (
4949
// comment
50-
a as any
51-
) as any;
50+
a
51+
);
5252
}
5353
function *t9() {
5454
yield (
5555
// comment
56-
a as any
57-
) satisfies any;
56+
a
57+
);
5858
}
5959
function *t10() {
6060
yield (
6161
// comment
62-
a as any
63-
)!;
62+
a
63+
);
6464
}
6565

6666
==================== Output ====================
67+
function* t1() {
68+
yield (
69+
// comment
70+
a
71+
);
72+
}
73+
function* t2() {
74+
yield (
75+
// comment
76+
a + 1
77+
);
78+
}
79+
function* t3() {
80+
yield (
81+
// comment
82+
a
83+
? 0
84+
: 1
85+
);
86+
}
87+
function* t4() {
88+
yield (
89+
// comment
90+
a.b
91+
);
92+
}
93+
function* t5() {
94+
yield (
95+
// comment
96+
a[a]
97+
);
98+
}
99+
function* t6() {
100+
yield (
101+
// comment
102+
a()
103+
);
104+
}
105+
function* t7() {
106+
yield (
107+
// comment
108+
a``
109+
);
110+
}
111+
function* t8() {
112+
yield (
113+
// comment
114+
a
115+
);
116+
}
117+
function* t9() {
118+
yield (
119+
// comment
120+
a
121+
);
122+
}
123+
function* t10() {
124+
yield (
125+
// comment
126+
a
127+
);
128+
}
67129

68130
===================== End =====================
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var longlonglonglonglonglong = /*#__PURE__*/_interopDefaultLegacy(aaaaaaaaaaaaaaa);
2+
var short = /*#__PURE__*/_interopDefaultLegacy(b);
3+
4+
const jestPackageJson =
5+
// eslint-disable-next-line @typescript-eslint/no-require-imports
6+
require(jestPath);
7+
8+
{
9+
sourcemap =
10+
/** @type {'inline' | 'hidden' | 'sourcemap'} */ (
11+
process.env.WORKER_MODE
12+
) || sourcemap;
13+
}
14+
15+
class A {
16+
#testerConfig;
17+
constructor() {
18+
let basePath: string | undefined =
19+
this.#testerConfig.languageOptions.parserOptions?.tsconfigRootDir;
20+
}
21+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
source: crates/oxc_formatter/tests/fixtures/mod.rs
3+
---
4+
==================== Input ====================
5+
var longlonglonglonglonglong = /*#__PURE__*/_interopDefaultLegacy(aaaaaaaaaaaaaaa);
6+
var short = /*#__PURE__*/_interopDefaultLegacy(b);
7+
8+
const jestPackageJson =
9+
// eslint-disable-next-line @typescript-eslint/no-require-imports
10+
require(jestPath);
11+
12+
{
13+
sourcemap =
14+
/** @type {'inline' | 'hidden' | 'sourcemap'} */ (
15+
process.env.WORKER_MODE
16+
) || sourcemap;
17+
}
18+
19+
class A {
20+
#testerConfig;
21+
constructor() {
22+
let basePath: string | undefined =
23+
this.#testerConfig.languageOptions.parserOptions?.tsconfigRootDir;
24+
}
25+
}
26+
27+
==================== Output ====================
28+
var longlonglonglonglonglong =
29+
/*#__PURE__*/ _interopDefaultLegacy(aaaaaaaaaaaaaaa);
30+
var short = /*#__PURE__*/ _interopDefaultLegacy(b);
31+
32+
const jestPackageJson =
33+
// eslint-disable-next-line @typescript-eslint/no-require-imports
34+
require(jestPath);
35+
36+
{
37+
sourcemap =
38+
/** @type {'inline' | 'hidden' | 'sourcemap'} */ (
39+
process.env.WORKER_MODE
40+
) || sourcemap;
41+
}
42+
43+
class A {
44+
#testerConfig;
45+
constructor() {
46+
let basePath: string | undefined =
47+
this.#testerConfig.languageOptions.parserOptions?.tsconfigRootDir;
48+
}
49+
}
50+
51+
===================== End =====================

0 commit comments

Comments
 (0)