diff options
Diffstat (limited to 'cli/tests/unit/write_file_test.ts')
-rw-r--r-- | cli/tests/unit/write_file_test.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cli/tests/unit/write_file_test.ts b/cli/tests/unit/write_file_test.ts index 78d0f5bad..5f1ffd7a6 100644 --- a/cli/tests/unit/write_file_test.ts +++ b/cli/tests/unit/write_file_test.ts @@ -379,6 +379,22 @@ Deno.test( }, ); +// Test that AbortController's cancel handle is cleaned-up correctly, and do not leak resources. +Deno.test( + { permissions: { read: true, write: true } }, + async function writeFileWithAbortSignalNotCalled() { + const ac = new AbortController(); + const enc = new TextEncoder(); + const data = enc.encode("Hello"); + const filename = Deno.makeTempDirSync() + "/test.txt"; + await Deno.writeFile(filename, data, { signal: ac.signal }); + const dataRead = Deno.readFileSync(filename); + const dec = new TextDecoder("utf-8"); + const actual = dec.decode(dataRead); + assertEquals(actual, "Hello"); + }, +); + function assertNotExists(filename: string | URL) { if (pathExists(filename)) { throw new Error(`The file ${filename} exists.`); |