From 7b040f28b3f87fe26a9e26e2f288e152d5735c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20do=20Carmo?= Date: Mon, 23 Jan 2017 14:39:40 -0300 Subject: [PATCH] test: expand test coverage of fs.js * test reading a file passing a not valid enconding Refs: https://coverage.nodejs.org/coverage-067be658f966dafe/root/internal/fs.js.html PR-URL: https://github.com/nodejs/node/pull/10947 Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Gibson Fahnestock --- test/parallel/test-fs-read-file-assert-encoding.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/parallel/test-fs-read-file-assert-encoding.js diff --git a/test/parallel/test-fs-read-file-assert-encoding.js b/test/parallel/test-fs-read-file-assert-encoding.js new file mode 100644 index 00000000000000..897bcd3bc98795 --- /dev/null +++ b/test/parallel/test-fs-read-file-assert-encoding.js @@ -0,0 +1,13 @@ +'use strict'; +require('../common'); + +const assert = require('assert'); +const fs = require('fs'); + +const encoding = 'foo-8'; +const filename = 'bar.txt'; + +assert.throws( + fs.readFile.bind(fs, filename, { encoding }, () => {}), + new RegExp(`Error: Unknown encoding: ${encoding}$`) +);