diff options
author | Benjamin Lupton <b@lupton.cc> | 2020-06-24 12:32:43 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-23 22:32:43 -0400 |
commit | 49c54c0805ab26410a62e0251fee3a28b98c0e13 (patch) | |
tree | b9fcb2713622f2739557f2caffd51d8bb454300b /std/node/_fs/promises/_fs_readFile_test.ts | |
parent | d16337cc9c59732fe81655482e08b72d844472e6 (diff) |
fix(std/node): fix readFile types, add encoding types (#6451)
Diffstat (limited to 'std/node/_fs/promises/_fs_readFile_test.ts')
-rw-r--r-- | std/node/_fs/promises/_fs_readFile_test.ts | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/std/node/_fs/promises/_fs_readFile_test.ts b/std/node/_fs/promises/_fs_readFile_test.ts index c92907fec..f5be2318b 100644 --- a/std/node/_fs/promises/_fs_readFile_test.ts +++ b/std/node/_fs/promises/_fs_readFile_test.ts @@ -7,24 +7,38 @@ const testData = path.resolve( ); Deno.test("readFileSuccess", async function () { - const data = await readFile(testData); + const data: Uint8Array = await readFile(testData); assert(data instanceof Uint8Array); - assertEquals(new TextDecoder().decode(data as Uint8Array), "hello world"); + assertEquals(new TextDecoder().decode(data), "hello world"); }); -Deno.test("readFileEncodeUtf8Success", async function () { - const data = await readFile(testData, { encoding: "utf8" }); +Deno.test("readFileBinarySuccess", async function () { + const data: Uint8Array = await readFile(testData, "binary"); + + assert(data instanceof Uint8Array); + assertEquals(new TextDecoder().decode(data), "hello world"); +}); + +Deno.test("readFileBinaryObjectSuccess", async function () { + const data: Uint8Array = await readFile(testData, { encoding: "binary" }); + + assert(data instanceof Uint8Array); + assertEquals(new TextDecoder().decode(data), "hello world"); +}); + +Deno.test("readFileStringObjectSuccess", async function () { + const data: string = await readFile(testData, { encoding: "utf8" }); assertEquals(typeof data, "string"); - assertEquals(data as string, "hello world"); + assertEquals(data, "hello world"); }); -Deno.test("readFileEncodingAsString", async function () { - const data = await readFile(testData, "utf8"); +Deno.test("readFileStringSuccess", async function () { + const data: string = await readFile(testData, "utf8"); assertEquals(typeof data, "string"); - assertEquals(data as string, "hello world"); + assertEquals(data, "hello world"); }); Deno.test("readFileError", async function () { |