TestInjectImport_Merge proves that repeated InjectImport calls for the same module collapse into a single statement and that specifiers are sorted by name regardless of the order they were appended.
(t *testing.T)
| 50 | // module collapse into a single statement and that specifiers are sorted by |
| 51 | // name regardless of the order they were appended. |
| 52 | func TestInjectImport_Merge(t *testing.T) { |
| 53 | t.Parallel() |
| 54 | |
| 55 | ts := loadTypescript(t) |
| 56 | ts.ApplyMutations( |
| 57 | config.InjectImport("zod", "z"), |
| 58 | config.InjectImport("zod", "AnyZod"), |
| 59 | ) |
| 60 | output, err := ts.Serialize() |
| 61 | require.NoError(t, err, "serialize") |
| 62 | |
| 63 | require.Contains(t, importBlock(t, output), |
| 64 | `import { AnyZod, z } from "zod";`, |
| 65 | "merged value import must include both specifiers in sorted order") |
| 66 | require.Equal(t, 1, strings.Count(output, `from "zod"`), |
| 67 | "zod import must be merged") |
| 68 | } |
| 69 | |
| 70 | // TestInjectImport_AliasAndType exercises the "Name=Alias" specifier shorthand |
| 71 | // and the type-only declaration form together. |
nothing calls this directly
no test coverage detected
searching dependent graphs…