Skip to content

Commit 7c0f244

Browse files
Updated tests for 'organize imports'.
1 parent 1b92a21 commit 7c0f244

File tree

1 file changed

+43
-11
lines changed

1 file changed

+43
-11
lines changed

src/testRunner/unittests/services/organizeImports.ts

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ namespace ts {
285285
});
286286
});
287287

288+
288289
describe("Baselines", () => {
289290

290291
const libFile = {
@@ -327,6 +328,16 @@ export const Other = 1;
327328
assert.isEmpty(changes);
328329
});
329330

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+
330341
testOrganizeImports("Renamed_used",
331342
{
332343
path: "/test.ts",
@@ -366,6 +377,16 @@ D();
366377
},
367378
libFile);
368379

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+
369390
testOrganizeImports("Unused_All",
370391
{
371392
path: "/test.ts",
@@ -377,14 +398,17 @@ import D from "lib";
377398
},
378399
libFile);
379400

380-
testOrganizeImports("Unused_Empty",
381-
{
401+
it("Unused_Empty", () => {
402+
const testFile = {
382403
path: "/test.ts",
383404
content: `
384405
import { } from "lib";
385406
`,
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+
});
388412

389413
testOrganizeImports("Unused_false_positive_module_augmentation",
390414
{
@@ -414,25 +438,33 @@ declare module 'caseless' {
414438
test(name: KeyType): boolean;
415439
}
416440
}`
417-
});
441+
});
418442

419-
testOrganizeImports("Unused_false_positive_shorthand_assignment",
420-
{
443+
it("Unused_false_positive_shorthand_assignment", () => {
444+
const testFile = {
421445
path: "/test.ts",
422446
content: `
423447
import { x } from "a";
424448
const o = { x };
425449
`
426-
});
450+
};
451+
const languageService = makeLanguageService(testFile);
452+
const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions);
453+
assert.isEmpty(changes);
454+
});
427455

428-
testOrganizeImports("Unused_false_positive_export_shorthand",
429-
{
456+
it("Unused_false_positive_export_shorthand", () => {
457+
const testFile = {
430458
path: "/test.ts",
431459
content: `
432460
import { x } from "a";
433461
export { x };
434462
`
435-
});
463+
};
464+
const languageService = makeLanguageService(testFile);
465+
const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions);
466+
assert.isEmpty(changes);
467+
});
436468

437469
testOrganizeImports("MoveToTop",
438470
{

0 commit comments

Comments
 (0)