Skip to content

Commit

Permalink
add test showing that TS caches files
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed May 10, 2020
1 parent 45f9b32 commit 258059a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cli/tests/compiler_api_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});

0 comments on commit 258059a

Please sign in to comment.