Skip to content

Commit 180b3f5

Browse files
committed
test: add back some tests for the deprecated behavior
1 parent 7c66ea6 commit 180b3f5

18 files changed

+836
-16
lines changed

test/rules/sort-array-includes.test.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,21 +1288,7 @@ describe('sort-array-includes', () => {
12881288
},
12891289
)
12901290

1291-
it('removes newlines between and inside groups', async () => {
1292-
let newlinesOptions = [
1293-
{
1294-
...options,
1295-
customGroups: [
1296-
{
1297-
elementNamePattern: 'a',
1298-
groupName: 'a',
1299-
},
1300-
],
1301-
groups: ['a', 'unknown'],
1302-
newlinesBetween: 0,
1303-
},
1304-
]
1305-
1291+
it('removes newlines between and inside groups by default when "newlinesBetween" is 0', async () => {
13061292
await invalid({
13071293
errors: [
13081294
{
@@ -1318,6 +1304,19 @@ describe('sort-array-includes', () => {
13181304
data: { right: 'b', left: 'z' },
13191305
},
13201306
],
1307+
options: [
1308+
{
1309+
...options,
1310+
customGroups: [
1311+
{
1312+
elementNamePattern: 'a',
1313+
groupName: 'a',
1314+
},
1315+
],
1316+
groups: ['a', 'unknown'],
1317+
newlinesBetween: 0,
1318+
},
1319+
],
13211320
code: dedent`
13221321
[
13231322
'a',
@@ -1337,7 +1336,6 @@ describe('sort-array-includes', () => {
13371336
'z'
13381337
].includes(value)
13391338
`,
1340-
options: newlinesOptions,
13411339
})
13421340
})
13431341

test/rules/sort-classes.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,6 +3825,51 @@ describe('sort-classes', () => {
38253825
})
38263826
})
38273827

3828+
it('removes newlines between and inside groups by default when "newlinesBetween" is 0', async () => {
3829+
await invalid({
3830+
errors: [
3831+
{
3832+
messageId: 'extraSpacingBetweenClassMembers',
3833+
data: { right: 'y', left: 'a' },
3834+
},
3835+
{
3836+
messageId: 'unexpectedClassesOrder',
3837+
data: { right: 'b', left: 'z' },
3838+
},
3839+
{
3840+
messageId: 'extraSpacingBetweenClassMembers',
3841+
data: { right: 'b', left: 'z' },
3842+
},
3843+
],
3844+
options: [
3845+
{
3846+
...options,
3847+
groups: ['method', 'unknown'],
3848+
newlinesBetween: 0,
3849+
},
3850+
],
3851+
code: dedent`
3852+
class Class {
3853+
a() {}
3854+
3855+
3856+
y = "y"
3857+
z = "z"
3858+
3859+
b = "b"
3860+
}
3861+
`,
3862+
output: dedent`
3863+
class Class {
3864+
a() {}
3865+
b = "b"
3866+
y = "y"
3867+
z = "z"
3868+
}
3869+
`,
3870+
})
3871+
})
3872+
38283873
it('removes newlines inside groups when newlinesInside is 0', async () => {
38293874
await invalid({
38303875
errors: [

test/rules/sort-decorators.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,55 @@ describe('sort-decorators', () => {
911911
})
912912
})
913913

914+
it('removes newlines between and inside groups by default when "newlinesBetween" is 0', async () => {
915+
await invalid({
916+
errors: [
917+
{
918+
messageId: 'extraSpacingBetweenDecorators',
919+
data: { right: 'y', left: 'a' },
920+
},
921+
{
922+
messageId: 'unexpectedDecoratorsOrder',
923+
data: { right: 'b', left: 'z' },
924+
},
925+
{
926+
messageId: 'extraSpacingBetweenDecorators',
927+
data: { right: 'b', left: 'z' },
928+
},
929+
],
930+
options: [
931+
{
932+
...options,
933+
customGroups: [
934+
{
935+
elementNamePattern: 'a',
936+
groupName: 'a',
937+
},
938+
],
939+
groups: ['a', 'unknown'],
940+
newlinesBetween: 0,
941+
},
942+
],
943+
code: dedent`
944+
@a
945+
946+
947+
@y
948+
@z
949+
950+
@b
951+
class Class {}
952+
`,
953+
output: dedent`
954+
@a
955+
@b
956+
@y
957+
@z
958+
class Class {}
959+
`,
960+
})
961+
})
962+
914963
it('removes newlines inside groups when newlinesInside is 0', async () => {
915964
await invalid({
916965
options: [

test/rules/sort-enums.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,57 @@ describe('sort-enums', () => {
10911091
})
10921092
})
10931093

1094+
it('removes newlines between and inside groups by default when "newlinesBetween" is 0', async () => {
1095+
await invalid({
1096+
errors: [
1097+
{
1098+
messageId: 'extraSpacingBetweenEnumsMembers',
1099+
data: { right: 'Y', left: 'A' },
1100+
},
1101+
{
1102+
messageId: 'unexpectedEnumsOrder',
1103+
data: { right: 'B', left: 'Z' },
1104+
},
1105+
{
1106+
messageId: 'extraSpacingBetweenEnumsMembers',
1107+
data: { right: 'B', left: 'Z' },
1108+
},
1109+
],
1110+
options: [
1111+
{
1112+
...options,
1113+
customGroups: [
1114+
{
1115+
elementNamePattern: 'A',
1116+
groupName: 'a',
1117+
},
1118+
],
1119+
groups: ['a', 'unknown'],
1120+
newlinesBetween: 0,
1121+
},
1122+
],
1123+
code: dedent`
1124+
enum Enum {
1125+
A = null,
1126+
1127+
1128+
Y = null,
1129+
Z = null,
1130+
1131+
B = null,
1132+
}
1133+
`,
1134+
output: dedent`
1135+
enum Enum {
1136+
A = null,
1137+
B = null,
1138+
Y = null,
1139+
Z = null,
1140+
}
1141+
`,
1142+
})
1143+
})
1144+
10941145
it('removes newlines inside groups when newlinesInside is 0', async () => {
10951146
await invalid({
10961147
options: [

test/rules/sort-exports.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,53 @@ describe('sort-exports', () => {
952952
})
953953
})
954954

955+
it('removes newlines between and inside groups by default when "newlinesBetween" is 0', async () => {
956+
await invalid({
957+
errors: [
958+
{
959+
messageId: 'extraSpacingBetweenExports',
960+
data: { right: 'y', left: 'a' },
961+
},
962+
{
963+
messageId: 'unexpectedExportsOrder',
964+
data: { right: 'b', left: 'z' },
965+
},
966+
{
967+
messageId: 'extraSpacingBetweenExports',
968+
data: { right: 'b', left: 'z' },
969+
},
970+
],
971+
options: [
972+
{
973+
...options,
974+
customGroups: [
975+
{
976+
elementNamePattern: 'a',
977+
groupName: 'a',
978+
},
979+
],
980+
groups: ['a', 'unknown'],
981+
newlinesBetween: 0,
982+
},
983+
],
984+
code: dedent`
985+
export { a } from 'a'
986+
987+
988+
export { y } from 'y'
989+
export { z } from 'z'
990+
991+
export { b } from 'b'
992+
`,
993+
output: dedent`
994+
export { a } from 'a'
995+
export { b } from 'b'
996+
export { y } from 'y'
997+
export { z } from 'z'
998+
`,
999+
})
1000+
})
1001+
9551002
it('removes newlines inside groups when newlinesInside is 0', async () => {
9561003
await invalid({
9571004
options: [

test/rules/sort-heritage-clauses.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,57 @@ describe('sort-heritage-clauses', () => {
522522
})
523523
})
524524

525+
it('removes newlines between and inside groups by default when "newlinesBetween" is 0', async () => {
526+
await invalid({
527+
errors: [
528+
{
529+
messageId: 'extraSpacingBetweenHeritageClauses',
530+
data: { right: 'y', left: 'a' },
531+
},
532+
{
533+
messageId: 'unexpectedHeritageClausesOrder',
534+
data: { right: 'b', left: 'z' },
535+
},
536+
{
537+
messageId: 'extraSpacingBetweenHeritageClauses',
538+
data: { right: 'b', left: 'z' },
539+
},
540+
],
541+
options: [
542+
{
543+
...options,
544+
customGroups: [
545+
{
546+
elementNamePattern: 'a',
547+
groupName: 'a',
548+
},
549+
],
550+
groups: ['a', 'unknown'],
551+
newlinesBetween: 0,
552+
},
553+
],
554+
code: dedent`
555+
class Class implements
556+
a,
557+
558+
559+
y,
560+
z,
561+
562+
b
563+
{}
564+
`,
565+
output: dedent`
566+
class Class implements
567+
a,
568+
b,
569+
y,
570+
z
571+
{}
572+
`,
573+
})
574+
})
575+
525576
it('removes newlines inside groups when newlinesInside is 0', async () => {
526577
await invalid({
527578
options: [

test/rules/sort-interfaces.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,51 @@ describe('sort-interfaces', () => {
17831783
})
17841784
})
17851785

1786+
it('removes newlines between and inside groups by default when "newlinesBetween" is 0', async () => {
1787+
await invalid({
1788+
errors: [
1789+
{
1790+
messageId: 'extraSpacingBetweenInterfaceMembers',
1791+
data: { right: 'y', left: 'a' },
1792+
},
1793+
{
1794+
messageId: 'unexpectedInterfacePropertiesOrder',
1795+
data: { right: 'b', left: 'z' },
1796+
},
1797+
{
1798+
messageId: 'extraSpacingBetweenInterfaceMembers',
1799+
data: { right: 'b', left: 'z' },
1800+
},
1801+
],
1802+
code: dedent`
1803+
interface Interface {
1804+
a: () => null,
1805+
1806+
1807+
y: "y",
1808+
z: "z",
1809+
1810+
b: "b",
1811+
}
1812+
`,
1813+
output: dedent`
1814+
interface Interface {
1815+
a: () => null,
1816+
b: "b",
1817+
y: "y",
1818+
z: "z",
1819+
}
1820+
`,
1821+
options: [
1822+
{
1823+
...options,
1824+
groups: ['method', 'unknown'],
1825+
newlinesBetween: 0,
1826+
},
1827+
],
1828+
})
1829+
})
1830+
17861831
it('removes newlines inside groups when newlinesInside is 0', async () => {
17871832
await invalid({
17881833
errors: [

0 commit comments

Comments
 (0)