From 524b1547b7c291763d6ca066ce8e10ae6398190b Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Thu, 14 May 2020 13:04:07 +0200 Subject: std/node fs.readFile should take string as option (#5316) --- std/node/_fs/_fs_readFile_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'std/node/_fs/_fs_readFile_test.ts') diff --git a/std/node/_fs/_fs_readFile_test.ts b/std/node/_fs/_fs_readFile_test.ts index 429ceb3f5..1a850c91a 100644 --- a/std/node/_fs/_fs_readFile_test.ts +++ b/std/node/_fs/_fs_readFile_test.ts @@ -35,6 +35,20 @@ test("readFileEncodeUtf8Success", async function () { assertEquals(data as string, "hello world"); }); +test("readFileEncodingAsString", async function () { + const data = await new Promise((res, rej) => { + readFile(testData, "utf8", (err, data) => { + if (err) { + rej(err); + } + res(data); + }); + }); + + assertEquals(typeof data, "string"); + assertEquals(data as string, "hello world"); +}); + test("readFileSyncSuccess", function () { const data = readFileSync(testData); assert(data instanceof Uint8Array); @@ -46,3 +60,9 @@ test("readFileEncodeUtf8Success", function () { assertEquals(typeof data, "string"); assertEquals(data as string, "hello world"); }); + +test("readFileEncodeAsString", function () { + const data = readFileSync(testData, "utf8"); + assertEquals(typeof data, "string"); + assertEquals(data as string, "hello world"); +}); -- cgit v1.2.3