diff --git a/cli/tests/compiler_api_test.ts b/cli/tests/compiler_api_test.ts index cdc2be6d28dbe7..417ef9bc2279d4 100644 --- a/cli/tests/compiler_api_test.ts +++ b/cli/tests/compiler_api_test.ts @@ -150,3 +150,25 @@ test("diagnosticsTest", async function () { assert(Array.isArray(diagnostics)); assert(diagnostics.length === 1); }); + +test(async function compileChangedFile() { + const source1 = "console.log(1);"; + const source2 = "console.log(2);"; + const tempDir = await Deno.makeTempDir(); + const filename = tempDir + "/test.ts"; + const jsFilename = "file://" + tempDir + "/test.js"; + const encoder = new TextEncoder(); + + await Deno.writeFile(filename, encoder.encode(source1)); + const [diagnostics1, emitMap1] = await compile(filename); + console.log(jsFilename, emitMap1); + assert(!diagnostics1); + assert(emitMap1[jsFilename]); + + await Deno.writeFile(filename, encoder.encode(source2)); + const [diagnostics2, emitMap2] = await compile(filename); + assert(!diagnostics2); + assert(emitMap2[jsFilename]); + + assert(emitMap1[jsFilename] !== emitMap2[jsFilename]); +});