@@ -285,6 +285,7 @@ namespace ts {
285
285
} ) ;
286
286
} ) ;
287
287
288
+
288
289
describe ( "Baselines" , ( ) => {
289
290
290
291
const libFile = {
@@ -327,6 +328,16 @@ export const Other = 1;
327
328
assert . isEmpty ( changes ) ;
328
329
} ) ;
329
330
331
+ it ( "doesn't return any changes when the text would be identical" , ( ) => {
332
+ const testFile = {
333
+ path : "/a.ts" ,
334
+ content : `import { f } from 'foo';\nf();`
335
+ } ;
336
+ const languageService = makeLanguageService ( testFile ) ;
337
+ const changes = languageService . organizeImports ( { type : "file" , fileName : testFile . path } , testFormatSettings , emptyOptions ) ;
338
+ assert . isEmpty ( changes ) ;
339
+ } ) ;
340
+
330
341
testOrganizeImports ( "Renamed_used" ,
331
342
{
332
343
path : "/test.ts" ,
@@ -366,6 +377,16 @@ D();
366
377
} ,
367
378
libFile ) ;
368
379
380
+ it ( "doesn't return any changes when the text would be identical" , ( ) => {
381
+ const testFile = {
382
+ path : "/a.ts" ,
383
+ content : `import { f } from 'foo';\nf();`
384
+ } ;
385
+ const languageService = makeLanguageService ( testFile ) ;
386
+ const changes = languageService . organizeImports ( { type : "file" , fileName : testFile . path } , testFormatSettings , emptyOptions ) ;
387
+ assert . isEmpty ( changes ) ;
388
+ } ) ;
389
+
369
390
testOrganizeImports ( "Unused_All" ,
370
391
{
371
392
path : "/test.ts" ,
@@ -377,14 +398,17 @@ import D from "lib";
377
398
} ,
378
399
libFile ) ;
379
400
380
- testOrganizeImports ( "Unused_Empty" ,
381
- {
401
+ it ( "Unused_Empty" , ( ) => {
402
+ const testFile = {
382
403
path : "/test.ts" ,
383
404
content : `
384
405
import { } from "lib";
385
406
` ,
386
- } ,
387
- libFile ) ;
407
+ } ;
408
+ const languageService = makeLanguageService ( testFile ) ;
409
+ const changes = languageService . organizeImports ( { type : "file" , fileName : testFile . path } , testFormatSettings , emptyOptions ) ;
410
+ assert . isEmpty ( changes ) ;
411
+ } ) ;
388
412
389
413
testOrganizeImports ( "Unused_false_positive_module_augmentation" ,
390
414
{
@@ -414,25 +438,33 @@ declare module 'caseless' {
414
438
test(name: KeyType): boolean;
415
439
}
416
440
}`
417
- } ) ;
441
+ } ) ;
418
442
419
- testOrganizeImports ( "Unused_false_positive_shorthand_assignment" ,
420
- {
443
+ it ( "Unused_false_positive_shorthand_assignment" , ( ) => {
444
+ const testFile = {
421
445
path : "/test.ts" ,
422
446
content : `
423
447
import { x } from "a";
424
448
const o = { x };
425
449
`
426
- } ) ;
450
+ } ;
451
+ const languageService = makeLanguageService ( testFile ) ;
452
+ const changes = languageService . organizeImports ( { type : "file" , fileName : testFile . path } , testFormatSettings , emptyOptions ) ;
453
+ assert . isEmpty ( changes ) ;
454
+ } ) ;
427
455
428
- testOrganizeImports ( "Unused_false_positive_export_shorthand" ,
429
- {
456
+ it ( "Unused_false_positive_export_shorthand" , ( ) => {
457
+ const testFile = {
430
458
path : "/test.ts" ,
431
459
content : `
432
460
import { x } from "a";
433
461
export { x };
434
462
`
435
- } ) ;
463
+ } ;
464
+ const languageService = makeLanguageService ( testFile ) ;
465
+ const changes = languageService . organizeImports ( { type : "file" , fileName : testFile . path } , testFormatSettings , emptyOptions ) ;
466
+ assert . isEmpty ( changes ) ;
467
+ } ) ;
436
468
437
469
testOrganizeImports ( "MoveToTop" ,
438
470
{
0 commit comments