提交 50e025e0 编写于 作者: D Daniel Imms

Terminal profile enum tests, fix arg formatting

Part of #129140
上级 f831c8d3
......@@ -11,19 +11,16 @@ export function createProfileSchemaEnums(detectedProfiles: ITerminalProfile[]):
values: string[] | undefined,
markdownDescriptions: string[] | undefined
} {
let values: string[] | undefined = undefined;
let markdownDescriptions: string[] | undefined = undefined;
if (detectedProfiles) {
const result = detectedProfiles.map(e => {
return {
name: e.profileName,
description: createProfileDescription(e)
};
});
values = result.map(e => e.name);
markdownDescriptions = result.map(e => e.description);
}
return { values, markdownDescriptions };
const result = detectedProfiles.map(e => {
return {
name: e.profileName,
description: createProfileDescription(e)
};
});
return {
values: result.map(e => e.name),
markdownDescriptions: result.map(e => e.description)
};
}
function createProfileDescription(profile: ITerminalProfile): string {
......@@ -32,7 +29,7 @@ function createProfileDescription(profile: ITerminalProfile): string {
if (typeof profile.args === 'string') {
description += `\n- args: "${profile.args}"`;
} else {
description += `\n- args: [${profile.args.length === 0 ? '' : profile.args.join(`','`)}]`;
description += `\n- args: [${profile.args.length === 0 ? '' : `'${profile.args.join(`','`)}'`}]`;
}
}
if (profile.overrideName !== undefined) {
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { deepStrictEqual } from 'assert';
import { Codicon } from 'vs/base/common/codicons';
import { ITerminalProfile } from 'vs/platform/terminal/common/terminal';
import { createProfileSchemaEnums } from 'vs/platform/terminal/common/terminalProfiles';
suite('terminalProfiles', () => {
suite('createProfileSchemaEnums', () => {
test('should return an empty array when there are no profiles', () => {
deepStrictEqual(createProfileSchemaEnums([]), {
values: [],
markdownDescriptions: []
});
});
test('should return a single entry when there is one profile', () => {
const profile: ITerminalProfile = {
profileName: 'name',
path: 'path',
isDefault: true
};
deepStrictEqual(createProfileSchemaEnums([profile]), {
values: ['name'],
markdownDescriptions: ['$(terminal) name\n- path: path']
});
});
test('should show all profile information', () => {
const profile: ITerminalProfile = {
profileName: 'name',
path: 'path',
isDefault: true,
args: ['a', 'b'],
color: 'terminal.ansiRed',
env: {
c: 'd',
e: 'f'
},
icon: Codicon.zap,
overrideName: true
};
deepStrictEqual(createProfileSchemaEnums([profile]), {
values: ['name'],
markdownDescriptions: [`$(zap) name\n- path: path\n- args: ['a','b']\n- overrideName: true\n- color: terminal.ansiRed\n- env: {\"c\":\"d\",\"e\":\"f\"}`]
});
});
test('should return a multiple entries when there are multiple profiles', () => {
const profile1: ITerminalProfile = {
profileName: 'name',
path: 'path',
isDefault: true
};
const profile2: ITerminalProfile = {
profileName: 'foo',
path: 'bar',
isDefault: false
};
deepStrictEqual(createProfileSchemaEnums([profile1, profile2]), {
values: ['name', 'foo'],
markdownDescriptions: [
'$(terminal) name\n- path: path',
'$(terminal) foo\n- path: bar'
]
});
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册