commonEditorConfig.test.ts 2.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

A
Alex Dima 已提交
7
import * as assert from 'assert';
A
Alex Dima 已提交
8
import {MockConfiguration} from 'vs/editor/test/common/mocks/mockConfiguration';
E
Erich Gamma 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

suite('Editor Config - CommonEditorConfig', () => {
	test('Configuration.normalizeIndentation', () => {
		var config = new MockConfiguration({
			insertSpaces: false,
			tabSize: 4
		});

		assert.equal(config.normalizeIndentation('\t'), '\t');
		assert.equal(config.normalizeIndentation('    '), '\t');
		assert.equal(config.normalizeIndentation('   '), '   ');
		assert.equal(config.normalizeIndentation('  '), '  ');
		assert.equal(config.normalizeIndentation(' '), ' ');
		assert.equal(config.normalizeIndentation(''), '');
		assert.equal(config.normalizeIndentation(' \t   '), '\t\t');
		assert.equal(config.normalizeIndentation(' \t  '), '\t   ');
		assert.equal(config.normalizeIndentation(' \t '), '\t  ');
		assert.equal(config.normalizeIndentation(' \t'), '\t ');

		assert.equal(config.normalizeIndentation('\ta'), '\ta');
		assert.equal(config.normalizeIndentation('    a'), '\ta');
		assert.equal(config.normalizeIndentation('   a'), '   a');
		assert.equal(config.normalizeIndentation('  a'), '  a');
		assert.equal(config.normalizeIndentation(' a'), ' a');
		assert.equal(config.normalizeIndentation('a'), 'a');
		assert.equal(config.normalizeIndentation(' \t   a'), '\t\ta');
		assert.equal(config.normalizeIndentation(' \t  a'), '\t   a');
		assert.equal(config.normalizeIndentation(' \t a'), '\t  a');
		assert.equal(config.normalizeIndentation(' \ta'), '\t a');

		config = new MockConfiguration({
			insertSpaces: true,
			tabSize: 4
		});

		assert.equal(config.normalizeIndentation('\ta'), '    a');
		assert.equal(config.normalizeIndentation('    a'), '    a');
		assert.equal(config.normalizeIndentation('   a'), '   a');
		assert.equal(config.normalizeIndentation('  a'), '  a');
		assert.equal(config.normalizeIndentation(' a'), ' a');
		assert.equal(config.normalizeIndentation('a'), 'a');
		assert.equal(config.normalizeIndentation(' \t   a'), '        a');
		assert.equal(config.normalizeIndentation(' \t  a'), '       a');
		assert.equal(config.normalizeIndentation(' \t a'), '      a');
		assert.equal(config.normalizeIndentation(' \ta'), '     a');
	});
});