Path: blob/main/extensions/copilot/src/extension/prompt/node/test/indentationGuesser.spec.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { describe, expect, it } from 'vitest';6import { transformIndentation } from '../indentationGuesser';78describe('identationGuesser', () => {9it('transformIndentation', () => {10expect(transformIndentation(' hello()', { insertSpaces: true, tabSize: 2 }, { insertSpaces: false, tabSize: 2 })).toBe('\thello()');1112// 4 spaces to 2-space indent13expect(transformIndentation(' hello()', { insertSpaces: true, tabSize: 4 }, { insertSpaces: true, tabSize: 2 })).toBe(' hello()');14// tab to 4 spaces15expect(transformIndentation('\thello()', { insertSpaces: false, tabSize: 4 }, { insertSpaces: true, tabSize: 4 })).toBe(' hello()');16// 8 spaces to tab (tabSize 4)17expect(transformIndentation(' hello()', { insertSpaces: true, tabSize: 4 }, { insertSpaces: false, tabSize: 4 })).toBe('\t\thello()');18// 2 tabs to 4 spaces (tabSize 2)19expect(transformIndentation('\t\thello()', { insertSpaces: false, tabSize: 2 }, { insertSpaces: true, tabSize: 4 })).toBe(' hello()');20// No indentation change21expect(transformIndentation('hello()', { insertSpaces: true, tabSize: 2 }, { insertSpaces: true, tabSize: 2 })).toBe('hello()');22expect(transformIndentation(' \thello()', { insertSpaces: false, tabSize: 4 }, { insertSpaces: true, tabSize: 2 })).toBe(' \thello()');23});24});252627