Skip to content

Commit 254a44b

Browse files
committed
Tests
1 parent e2dc003 commit 254a44b

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// Issue #22273 - Should retain space after comma in import attributes
1+
// Issue #22273 - Should have a space after commas in import attributes
22
import myEmbeddedDb from './my.db' with { type: 'sqlite', embed: 'true' }
3+
import myEmbeddedDb2 from './my.db' with {type: 'sqlite',embed: 'true'}
4+
import myEmbeddedDb3 from './my.db' with { embed: 'true', type: 'sqlite' }
35

4-
// Should be spread over multiple lines
5-
import myEmbeddedDb from './my.db' with { type: 'sqlite', embed: 'true', veryLongAttribute: "true" }
6-
7-
// Shouldn't have a comma for a single attribute
8-
import myEmbeddedDb from './my.db' with { type: 'sqlite' }
9-
10-
6+
// Should spread over multiple lines
7+
import myEmbeddedDb4 from './my.db' with { type: 'sqlite', embed: 'true', veryLongAttribute: 'true' }
8+
import myEmbeddedDb5 from './my.db' with { veryVeryVeryVeryVeryVeryVeryVeryVeryLongAttribute: 'true' }

crates/oxc_formatter/tests/fixtures/js/import-attributes/issue-22273.mjs.snap

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,50 @@
22
source: crates/oxc_formatter/tests/fixtures/mod.rs
33
---
44
==================== Input ====================
5-
// Issue #22273 - Should retain space after comma in import attributes
5+
// Issue #22273 - Should have a space after commas in import attributes
66
import myEmbeddedDb from './my.db' with { type: 'sqlite', embed: 'true' }
7+
import myEmbeddedDb2 from './my.db' with {type: 'sqlite',embed: 'true'}
8+
import myEmbeddedDb3 from './my.db' with { embed: 'true', type: 'sqlite' }
79

8-
// Should be spread over multiple lines
9-
import myEmbeddedDb from './my.db' with { type: 'sqlite', embed: 'true', veryLongAttribute: "true" }
10-
11-
// Shouldn't have a comma for a single attribute
12-
import myEmbeddedDb from './my.db' with { type: 'sqlite' }
13-
14-
10+
// Should spread over multiple lines
11+
import myEmbeddedDb4 from './my.db' with { type: 'sqlite', embed: 'true', veryLongAttribute: 'true' }
12+
import myEmbeddedDb5 from './my.db' with { veryVeryVeryVeryVeryVeryVeryVeryVeryLongAttribute: 'true' }
1513

1614
==================== Output ====================
1715
------------------
1816
{ printWidth: 80 }
1917
------------------
20-
// Issue #22273 - Should retain space after comma in import attributes
18+
// Issue #22273 - Should have a space after commas in import attributes
2119
import myEmbeddedDb from "./my.db" with { type: "sqlite", embed: "true" };
20+
import myEmbeddedDb2 from "./my.db" with { type: "sqlite", embed: "true" };
21+
import myEmbeddedDb3 from "./my.db" with { embed: "true", type: "sqlite" };
2222

23-
// Should be spread over multiple lines
24-
import myEmbeddedDb from "./my.db" with {
23+
// Should spread over multiple lines
24+
import myEmbeddedDb4 from "./my.db" with {
2525
type: "sqlite",
2626
embed: "true",
2727
veryLongAttribute: "true",
2828
};
29-
30-
// Shouldn't have a comma for a single attribute
31-
import myEmbeddedDb from "./my.db" with { type: "sqlite" };
29+
import myEmbeddedDb5 from "./my.db" with {
30+
veryVeryVeryVeryVeryVeryVeryVeryVeryLongAttribute: "true",
31+
};
3232

3333
-------------------
3434
{ printWidth: 100 }
3535
-------------------
36-
// Issue #22273 - Should retain space after comma in import attributes
36+
// Issue #22273 - Should have a space after commas in import attributes
3737
import myEmbeddedDb from "./my.db" with { type: "sqlite", embed: "true" };
38+
import myEmbeddedDb2 from "./my.db" with { type: "sqlite", embed: "true" };
39+
import myEmbeddedDb3 from "./my.db" with { embed: "true", type: "sqlite" };
3840

39-
// Should be spread over multiple lines
40-
import myEmbeddedDb from "./my.db" with {
41+
// Should spread over multiple lines
42+
import myEmbeddedDb4 from "./my.db" with {
4143
type: "sqlite",
4244
embed: "true",
4345
veryLongAttribute: "true",
4446
};
45-
46-
// Shouldn't have a comma for a single attribute
47-
import myEmbeddedDb from "./my.db" with { type: "sqlite" };
47+
import myEmbeddedDb5 from "./my.db" with {
48+
veryVeryVeryVeryVeryVeryVeryVeryVeryLongAttribute: "true",
49+
};
4850

4951
===================== End =====================

0 commit comments

Comments
 (0)