diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/write_file_test.ts | 16 | ||||
-rw-r--r-- | cli/tests/unit/write_text_file_test.ts | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/cli/tests/unit/write_file_test.ts b/cli/tests/unit/write_file_test.ts index 0c3ff491d..78d0f5bad 100644 --- a/cli/tests/unit/write_file_test.ts +++ b/cli/tests/unit/write_file_test.ts @@ -393,3 +393,19 @@ function pathExists(path: string | URL) { return false; } } + +Deno.test( + { permissions: { read: true, write: true } }, + async function writeFileStream() { + const stream = new ReadableStream({ + pull(controller) { + controller.enqueue(new Uint8Array([1])); + controller.enqueue(new Uint8Array([2])); + controller.close(); + }, + }); + const filename = Deno.makeTempDirSync() + "/test.txt"; + await Deno.writeFile(filename, stream); + assertEquals(Deno.readFileSync(filename), new Uint8Array([1, 2])); + }, +); diff --git a/cli/tests/unit/write_text_file_test.ts b/cli/tests/unit/write_text_file_test.ts index c83534928..ee9cac177 100644 --- a/cli/tests/unit/write_text_file_test.ts +++ b/cli/tests/unit/write_text_file_test.ts @@ -198,3 +198,19 @@ Deno.test( assertEquals(Deno.readTextFileSync(filename), "Hello"); }, ); + +Deno.test( + { permissions: { read: true, write: true } }, + async function writeTextFileStream() { + const stream = new ReadableStream({ + pull(controller) { + controller.enqueue("Hello"); + controller.enqueue("World"); + controller.close(); + }, + }); + const filename = Deno.makeTempDirSync() + "/test.txt"; + await Deno.writeTextFile(filename, stream); + assertEquals(Deno.readTextFileSync(filename), "HelloWorld"); + }, +); |