mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
make argv handling reusable
This commit is contained in:
@@ -3,37 +3,55 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { formatOptions } from 'vs/platform/environment/node/argv';
|
||||
import { formatOptions, Option } from 'vs/platform/environment/node/argv';
|
||||
|
||||
suite('formatOptions', () => {
|
||||
|
||||
function o(id: string, description: string): Option {
|
||||
return {
|
||||
id, description, type: 'string'
|
||||
};
|
||||
}
|
||||
|
||||
test('Text should display small columns correctly', () => {
|
||||
assert.equal(formatOptions({ 'foo': 'bar' }, 80), ' foo bar');
|
||||
assert.equal(
|
||||
formatOptions({
|
||||
'f': 'bar',
|
||||
'fo': 'ba',
|
||||
'foo': 'b'
|
||||
}, 80),
|
||||
' f bar\n' +
|
||||
' fo ba\n' +
|
||||
' foo b');
|
||||
assert.deepEqual(
|
||||
formatOptions([
|
||||
o('foo', 'bar')
|
||||
], 80),
|
||||
[' --foo bar']
|
||||
);
|
||||
assert.deepEqual(
|
||||
formatOptions([
|
||||
o('f', 'bar'),
|
||||
o('fo', 'ba'),
|
||||
o('foo', 'b')
|
||||
], 80),
|
||||
[
|
||||
' --f bar',
|
||||
' --fo ba',
|
||||
' --foo b'
|
||||
]);
|
||||
});
|
||||
|
||||
test('Text should wrap', () => {
|
||||
assert.equal(
|
||||
formatOptions({
|
||||
'foo': (<any>'bar ').repeat(9)
|
||||
}, 40),
|
||||
' foo bar bar bar bar bar bar bar bar\n' +
|
||||
' bar');
|
||||
assert.deepEqual(
|
||||
formatOptions([
|
||||
o('foo', (<any>'bar ').repeat(9))
|
||||
], 40),
|
||||
[
|
||||
' --foo bar bar bar bar bar bar bar bar',
|
||||
' bar'
|
||||
]);
|
||||
});
|
||||
|
||||
test('Text should revert to the condensed view when the terminal is too narrow', () => {
|
||||
assert.equal(
|
||||
formatOptions({
|
||||
'foo': (<any>'bar ').repeat(9)
|
||||
}, 30),
|
||||
' foo\n' +
|
||||
' bar bar bar bar bar bar bar bar bar ');
|
||||
assert.deepEqual(
|
||||
formatOptions([
|
||||
o('foo', (<any>'bar ').repeat(9))
|
||||
], 30),
|
||||
[
|
||||
' --foo',
|
||||
' bar bar bar bar bar bar bar bar bar '
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user