From 20b0a5125a80c027f21472eec98f29e5e35629fb Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Tue, 22 Jun 2021 18:45:26 +0300 Subject: feat(core): support AbortSignal in readFile (#10943) --- cli/tests/unit/read_file_test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/read_file_test.ts b/cli/tests/unit/read_file_test.ts index 5f8ee2c11..d8d1cddf2 100644 --- a/cli/tests/unit/read_file_test.ts +++ b/cli/tests/unit/read_file_test.ts @@ -95,3 +95,25 @@ unitTest( assertEquals(resourcesBefore, Deno.resources()); }, ); + +unitTest( + { perms: { read: true } }, + async function readFileWithAbortSignal(): Promise { + const ac = new AbortController(); + queueMicrotask(() => ac.abort()); + await assertThrowsAsync(async () => { + await Deno.readFile("cli/tests/fixture.json", { signal: ac.signal }); + }); + }, +); + +unitTest( + { perms: { read: true } }, + async function readTextileWithAbortSignal(): Promise { + const ac = new AbortController(); + queueMicrotask(() => ac.abort()); + await assertThrowsAsync(async () => { + await Deno.readTextFile("cli/tests/fixture.json", { signal: ac.signal }); + }); + }, +); -- cgit v1.2.3