@@ -73,16 +73,16 @@ func TestCompareImportsOrRequireStatements_ModuleSpecifiers(t *testing.T) {
73
73
for _ , tt := range tests {
74
74
t .Run (tt .name , func (t * testing.T ) {
75
75
t .Parallel ()
76
-
76
+
77
77
imports1 := parseImports (t , tt .import1 )
78
78
imports2 := parseImports (t , tt .import2 )
79
-
79
+
80
80
assert .Assert (t , len (imports1 ) == 1 , "Expected 1 import in import1" )
81
81
assert .Assert (t , len (imports2 ) == 1 , "Expected 1 import in import2" )
82
-
82
+
83
83
comparer := strings .Compare
84
84
result := ls .CompareImportsOrRequireStatements (imports1 [0 ], imports2 [0 ], comparer )
85
-
85
+
86
86
if tt .expected == 0 {
87
87
assert .Equal (t , 0 , result , "Expected imports to be equal" )
88
88
} else if tt .expected < 0 {
@@ -132,16 +132,16 @@ func TestCompareImportsOrRequireStatements_ImportKind(t *testing.T) {
132
132
for _ , tt := range tests {
133
133
t .Run (tt .name , func (t * testing.T ) {
134
134
t .Parallel ()
135
-
135
+
136
136
imports1 := parseImports (t , tt .import1 )
137
137
imports2 := parseImports (t , tt .import2 )
138
-
138
+
139
139
assert .Assert (t , len (imports1 ) == 1 , "Expected 1 import in import1" )
140
140
assert .Assert (t , len (imports2 ) == 1 , "Expected 1 import in import2" )
141
-
141
+
142
142
comparer := strings .Compare
143
143
result := ls .CompareImportsOrRequireStatements (imports1 [0 ], imports2 [0 ], comparer )
144
-
144
+
145
145
if tt .expected < 0 {
146
146
assert .Assert (t , result < 0 , "Expected import1 < import2, got %d" , result )
147
147
} else if tt .expected > 0 {
@@ -175,7 +175,7 @@ import * as namespace from "namespace-lib";
175
175
}
176
176
177
177
index := ls .GetImportDeclarationInsertIndex (imports , newImports [0 ], comparer )
178
- assert .Assert (t , index >= 0 && index <= len (imports ),
178
+ assert .Assert (t , index >= 0 && index <= len (imports ),
179
179
"Insert index %d out of range [0, %d]" , index , len (imports ))
180
180
}
181
181
@@ -222,7 +222,7 @@ func TestCompareImports_RelativeVsAbsolute(t *testing.T) {
222
222
for _ , tt := range tests {
223
223
t .Run (tt .name , func (t * testing.T ) {
224
224
t .Parallel ()
225
-
225
+
226
226
var imports []* ast.Statement
227
227
for _ , imp := range tt .imports {
228
228
parsed := parseImports (t , imp )
@@ -233,7 +233,7 @@ func TestCompareImports_RelativeVsAbsolute(t *testing.T) {
233
233
comparer := func (a , b * ast.Statement ) int {
234
234
return ls .CompareImportsOrRequireStatements (a , b , strings .Compare )
235
235
}
236
-
236
+
237
237
for i := 0 ; i < len (imports ); i ++ {
238
238
for j := i + 1 ; j < len (imports ); j ++ {
239
239
if comparer (imports [i ], imports [j ]) > 0 {
@@ -245,14 +245,14 @@ func TestCompareImports_RelativeVsAbsolute(t *testing.T) {
245
245
for i , want := range tt .want {
246
246
wantImports := parseImports (t , want )
247
247
assert .Assert (t , len (wantImports ) == 1 , "Expected 1 wanted import" )
248
-
248
+
249
249
gotSpec := ls .GetModuleSpecifierExpression (imports [i ])
250
250
wantSpec := ls .GetModuleSpecifierExpression (wantImports [0 ])
251
-
251
+
252
252
if gotSpec != nil && wantSpec != nil {
253
253
assert .Assert (t , ast .IsStringLiteral (gotSpec ), "Expected string literal in got" )
254
254
assert .Assert (t , ast .IsStringLiteral (wantSpec ), "Expected string literal in want" )
255
-
255
+
256
256
gotText := gotSpec .AsStringLiteral ().Text
257
257
wantText := wantSpec .AsStringLiteral ().Text
258
258
assert .Equal (t , wantText , gotText , "Import at position %d doesn't match" , i )
@@ -315,10 +315,10 @@ func TestGetModuleSpecifierExpression(t *testing.T) {
315
315
316
316
stmt := sourceFile .Statements .Nodes [0 ]
317
317
expr := ls .GetModuleSpecifierExpression (stmt )
318
-
318
+
319
319
assert .Assert (t , expr != nil , "Expected non-nil module specifier" )
320
320
assert .Assert (t , ast .IsStringLiteral (expr ), "Expected string literal" )
321
-
321
+
322
322
gotText := expr .AsStringLiteral ().Text
323
323
assert .Equal (t , tt .expected , gotText )
324
324
})
@@ -378,4 +378,4 @@ func TestCompareImportsWithDifferentTypes(t *testing.T) {
378
378
}
379
379
})
380
380
}
381
- }
381
+ }
0 commit comments