mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-14 04:00:38 +01:00
27256832f3
This reverts commit 7de696a202.
Seems to have broken loading vs/nls in at least one case in insiders
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
'use strict';
|
|
|
|
import assert = require('assert');
|
|
|
|
import encoding = require('vs/base/node/encoding');
|
|
import { encodingExists } from 'vs/base/node/encoding';
|
|
|
|
suite('Encoding', () => {
|
|
test('detectBOM UTF-8', () => {
|
|
const file = require.toUrl('./fixtures/some_utf8.css');
|
|
|
|
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
|
assert.equal(encoding, 'utf8');
|
|
});
|
|
});
|
|
|
|
test('detectBOM UTF-16 LE', () => {
|
|
const file = require.toUrl('./fixtures/some_utf16le.css');
|
|
|
|
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
|
assert.equal(encoding, 'utf16le');
|
|
});
|
|
});
|
|
|
|
test('detectBOM UTF-16 BE', () => {
|
|
const file = require.toUrl('./fixtures/some_utf16be.css');
|
|
|
|
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
|
assert.equal(encoding, 'utf16be');
|
|
});
|
|
});
|
|
|
|
test('detectBOM ANSI', function () {
|
|
const file = require.toUrl('./fixtures/some_ansi.css');
|
|
|
|
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
|
assert.equal(encoding, null);
|
|
});
|
|
});
|
|
|
|
test('detectBOM ANSI', function () {
|
|
const file = require.toUrl('./fixtures/empty.txt');
|
|
|
|
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
|
assert.equal(encoding, null);
|
|
});
|
|
});
|
|
|
|
test('resolve terminal encoding (detect)', function () {
|
|
return encoding.resolveTerminalEncoding().then(encoding => {
|
|
assert.ok(encodingExists(encoding));
|
|
});
|
|
});
|
|
|
|
test('resolve terminal encoding (environment)', function () {
|
|
process.env['VSCODE_CLI_ENCODING'] = 'utf16le';
|
|
|
|
return encoding.resolveTerminalEncoding().then(encoding => {
|
|
assert.ok(encodingExists(encoding));
|
|
assert.equal(encoding, 'utf16le');
|
|
});
|
|
});
|
|
});
|