|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import { strictEqual } from 'assert'; |
| 7 | +import { collapseTildePath } from 'vs/platform/terminal/common/terminalEnvironment'; |
| 8 | + |
| 9 | +suite('terminalEnvironment', () => { |
| 10 | + suite('collapseTildePath', () => { |
| 11 | + test('should return empty string for a falsy path', () => { |
| 12 | + strictEqual(collapseTildePath('', '/foo', '/'), ''); |
| 13 | + strictEqual(collapseTildePath(undefined, '/foo', '/'), ''); |
| 14 | + }); |
| 15 | + test('should return path for a falsy user home', () => { |
| 16 | + strictEqual(collapseTildePath('/foo', '', '/'), '/foo'); |
| 17 | + strictEqual(collapseTildePath('/foo', undefined, '/'), '/foo'); |
| 18 | + }); |
| 19 | + test('should not collapse when user home isn\'t present', () => { |
| 20 | + strictEqual(collapseTildePath('/foo', '/bar', '/'), '/foo'); |
| 21 | + strictEqual(collapseTildePath('C:\\foo', 'C:\\bar', '\\'), 'C:\\foo'); |
| 22 | + }); |
| 23 | + test('should collapse with Windows separators', () => { |
| 24 | + strictEqual(collapseTildePath('C:\\foo\\bar', 'C:\\foo', '\\'), '~\\bar'); |
| 25 | + strictEqual(collapseTildePath('C:\\foo\\bar', 'C:\\foo\\', '\\'), '~\\bar'); |
| 26 | + strictEqual(collapseTildePath('C:\\foo\\bar\\baz', 'C:\\foo\\', '\\'), '~\\bar\\baz'); |
| 27 | + strictEqual(collapseTildePath('C:\\foo\\bar\\baz', 'C:\\foo', '\\'), '~\\bar\\baz'); |
| 28 | + }); |
| 29 | + test('should collapse mixed case with Windows separators', () => { |
| 30 | + strictEqual(collapseTildePath('c:\\foo\\bar', 'C:\\foo', '\\'), '~\\bar'); |
| 31 | + strictEqual(collapseTildePath('C:\\foo\\bar\\baz', 'c:\\foo', '\\'), '~\\bar\\baz'); |
| 32 | + }); |
| 33 | + test('should collapse with Posix separators', () => { |
| 34 | + strictEqual(collapseTildePath('/foo/bar', '/foo', '/'), '~/bar'); |
| 35 | + strictEqual(collapseTildePath('/foo/bar', '/foo/', '/'), '~/bar'); |
| 36 | + strictEqual(collapseTildePath('/foo/bar/baz', '/foo', '/'), '~/bar/baz'); |
| 37 | + strictEqual(collapseTildePath('/foo/bar/baz', '/foo/', '/'), '~/bar/baz'); |
| 38 | + }); |
| 39 | + }); |
| 40 | +}); |
0 commit comments