Files
node/test/parallel/test-internal-util-normalizeencoding.js
Brian White ce5157b22f lib: remove usc-2 encoding
Fixes: https://github.com/nodejs/node/issues/21963
PR-URL: https://github.com/nodejs/node/pull/21964
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-07-27 21:03:11 +02:00

49 lines
1.0 KiB
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
const util = require('internal/util');
const tests = [
[undefined, 'utf8'],
[null, 'utf8'],
['', 'utf8'],
['utf8', 'utf8'],
['utf-8', 'utf8'],
['UTF-8', 'utf8'],
['UTF8', 'utf8'],
['Utf8', 'utf8'],
['uTf-8', 'utf8'],
['utF-8', 'utf8'],
['ucs2', 'utf16le'],
['UCS2', 'utf16le'],
['ucs-2', 'utf16le'],
['UCS-2', 'utf16le'],
['UcS-2', 'utf16le'],
['utf16le', 'utf16le'],
['utf-16le', 'utf16le'],
['UTF-16LE', 'utf16le'],
['UTF16LE', 'utf16le'],
['binary', 'latin1'],
['BINARY', 'latin1'],
['latin1', 'latin1'],
['LaTiN1', 'latin1'],
['base64', 'base64'],
['BASE64', 'base64'],
['hex', 'hex'],
['HEX', 'hex'],
['foo', undefined],
[1, undefined],
[false, undefined],
[NaN, undefined],
[0, undefined],
[[], undefined],
[{}, undefined]
];
tests.forEach((e, i) => {
const res = util.normalizeEncoding(e[0]);
assert.strictEqual(res, e[1], `#${i} failed: expected ${e[1]}, got ${res}`);
});