diff --git a/test/parallel/test-whatwg-encoding-textdecoder-fatal.js b/test/parallel/test-whatwg-encoding-custom-textdecoder-fatal.js similarity index 92% rename from test/parallel/test-whatwg-encoding-textdecoder-fatal.js rename to test/parallel/test-whatwg-encoding-custom-textdecoder-fatal.js index aa945b61b10e72..c5e4b9684b190f 100644 --- a/test/parallel/test-whatwg-encoding-textdecoder-fatal.js +++ b/test/parallel/test-whatwg-encoding-custom-textdecoder-fatal.js @@ -1,6 +1,7 @@ 'use strict'; // From: https://github.com/w3c/web-platform-tests/blob/39a67e2fff/encoding/textdecoder-fatal.html +// With the twist that we specifically test for Node.js error codes const common = require('../common'); @@ -82,21 +83,10 @@ bad.forEach((t) => { ); }); +// TODO(joyeecheung): remove this when WPT is ported { assert('fatal' in new TextDecoder()); assert.strictEqual(typeof new TextDecoder().fatal, 'boolean'); assert(!new TextDecoder().fatal); assert(new TextDecoder('utf-8', { fatal: true }).fatal); } - -{ - const notArrayBufferViewExamples = [false, {}, 1, '', new Error()]; - notArrayBufferViewExamples.forEach((invalidInputType) => { - common.expectsError(() => { - new TextDecoder(undefined, null).decode(invalidInputType); - }, { - code: 'ERR_INVALID_ARG_TYPE', - type: TypeError - }); - }); -} diff --git a/test/parallel/test-whatwg-encoding-custom-textdecoder-invalid-arg.js b/test/parallel/test-whatwg-encoding-custom-textdecoder-invalid-arg.js new file mode 100644 index 00000000000000..a2b56ad9577271 --- /dev/null +++ b/test/parallel/test-whatwg-encoding-custom-textdecoder-invalid-arg.js @@ -0,0 +1,18 @@ +'use strict'; + +// This tests that ERR_INVALID_ARG_TYPE are thrown when +// invalid arguments are passed to TextDecoder. + +const common = require('../common'); + +{ + const notArrayBufferViewExamples = [false, {}, 1, '', new Error()]; + notArrayBufferViewExamples.forEach((invalidInputType) => { + common.expectsError(() => { + new TextDecoder(undefined, null).decode(invalidInputType); + }, { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError + }); + }); +}