testImportRenamedIsSavedAsText
An import from outside the codebase renamed in a scratch file (join_1, as an older tcm stored it from a file that
had another join, made join) is saved as the text it is, as a comment changed is: the definition reads so,
its hash the same.
import { okIn, tempDir } from "#codebase/tcmts/cli/test/e2e/harness"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testImportRenamedIsSavedAsText = () => { const dir = tempDir("import renamed is text"); const ok = (...args: string[]) => okIn(dir, ...args); ok("init"); fs.writeFileSync( path.join(dir, "scratch.ts"), `// tcm: namespace posix\nimport { join as join_1 } from "node:path/posix";\nexport const place = (f: string): string => join_1("b", f);\n`, ); ok("add"); const before = /#(\w+)/.exec(ok("view", "posix.place"))![1]; ok("edit", "posix.place", "--force"); const scratch = path.join(dir, "scratch.ts"); fs.writeFileSync( scratch, fs.readFileSync(scratch, "utf8").replaceAll("join_1", "join").replace("join as join", "join"), ); const out = ok("update"); assert.match(out, /~ text +posix\.place/, out); const view = ok("view", "posix.place"); assert.match(view, /import \{ join \} from "node:path\/posix";[\s\S]*join\("b", f\)/, view); assert.equal(/#(\w+)/.exec(view)![1], before); }