testPatchImportLines
tcmts.cli.main.testPatchImportLines · #e73o2spy · term
import { patchImportLines } from "#codebase/tcmts/cli/main";
import assert from "node:assert/strict";
export const testPatchImportLines = () => {
assert.deepEqual(
patchImportLines([
{ name: "isImportDeclaration", from: "typescript", as: "ts_isImportDeclaration" },
{ name: "join", from: "node:path" },
{ name: "default", from: "node:fs", as: "fs" },
{ name: "*", from: "typescript", as: "ts" },
{ name: "Codebase", from: "#codebase/tcmts/cli/codebase", type: true },
]),
[
'import { isImportDeclaration as ts_isImportDeclaration } from "typescript";',
'import { join } from "node:path";',
'import fs from "node:fs";',
'import * as ts from "typescript";',
'import type { Codebase } from "#codebase/tcmts/cli/codebase";',
],
);
assert.throws(() => patchImportLines([{ name: "*", from: "typescript" }]), /`\*` with `as`/);
assert.throws(() => patchImportLines([{ name: "x", from: "" }]), /nothing it's from/);
assert.throws(() => patchImportLines([{ name: "a b", from: "m" }]), /isn't one/);
}
uses