MCPcopy Create free account
hub / github.com/coder/guts / TestInjectImport_SortedAcrossModules

Function TestInjectImport_SortedAcrossModules

imports_test.go:120–138  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

118// it must be alphabetical by module, not append order. Calling the mutations
119// in reverse alphabetical order should still yield the same output.
120func 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.

Callers

nothing calls this directly

Calls 6

InjectImportFunction · 0.92
InjectTypeImportFunction · 0.92
loadTypescriptFunction · 0.85
importBlockFunction · 0.85
ApplyMutationsMethod · 0.80
SerializeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…