TestInjectImport_SortedAcrossModules pins the cross-module emission order: it must be alphabetical by module, not append order. Calling the mutations in reverse alphabetical order should still yield the same output.
(t *testing.T)
| 118 | // it must be alphabetical by module, not append order. Calling the mutations |
| 119 | // in reverse alphabetical order should still yield the same output. |
| 120 | func TestInjectImport_SortedAcrossModules(t *testing.T) { |
| 121 | t.Parallel() |
| 122 | |
| 123 | ts := loadTypescript(t) |
| 124 | ts.ApplyMutations( |
| 125 | config.InjectImport("zod", "z"), |
| 126 | config.InjectTypeImport("./types", "Foo"), |
| 127 | ) |
| 128 | output, err := ts.Serialize() |
| 129 | require.NoError(t, err, "serialize") |
| 130 | |
| 131 | block := importBlock(t, output) |
| 132 | typesIdx := strings.Index(block, `from "./types"`) |
| 133 | zodIdx := strings.Index(block, `from "zod"`) |
| 134 | require.GreaterOrEqual(t, typesIdx, 0, "./types import must appear") |
| 135 | require.GreaterOrEqual(t, zodIdx, 0, "zod import must appear") |
| 136 | require.Less(t, typesIdx, zodIdx, |
| 137 | "imports must be sorted alphabetically by module") |
| 138 | } |
| 139 | |
| 140 | // TestInjectSideEffectImport exercises the bare-import form, deduplication, |
| 141 | // and per-module placement against a clausal import for the same module. |
nothing calls this directly
no test coverage detected
searching dependent graphs…