Skip to content

Commit 01d41e8

Browse files
committed
⚗️ Add tests to verify parseKeyValueAssignment function
Signed-off-by: Babak K. Shandiz <[email protected]>
1 parent 6b85ac7 commit 01d41e8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/vs/workbench/contrib/terminal/test/browser/xterm/shellIntegrationAddon.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Terminal } from 'xterm';
77
import { strictEqual, deepStrictEqual } from 'assert';
88
import { timeout } from 'vs/base/common/async';
99
import * as sinon from 'sinon';
10-
import { ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon';
10+
import { parseKeyValueAssignment, ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon';
1111
import { ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
1212
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1313
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
@@ -197,3 +197,23 @@ suite('ShellIntegrationAddon', () => {
197197
});
198198
});
199199
});
200+
201+
test('parseKeyValueAssignment', () => {
202+
type TestCase = [title: string, input: string, expected: [key: string, value: string | undefined]];
203+
const cases: TestCase[] = [
204+
['empty', '', ['', undefined]],
205+
['no "=" sign', 'some-text', ['some-text', undefined]],
206+
['empty value', 'key=', ['key', '']],
207+
['empty key', '=value', ['', 'value']],
208+
['normal', 'key=value', ['key', 'value']],
209+
['multiple "=" signs (1)', 'key==value', ['key', '=value']],
210+
['multiple "=" signs (2)', 'key=value===true', ['key', 'value===true']],
211+
['just a "="', '=', ['', '']],
212+
['just a "=="', '==', ['', '=']],
213+
];
214+
215+
cases.forEach(x => {
216+
const [title, input, [key, value]] = x;
217+
deepStrictEqual(parseKeyValueAssignment(input), { key, value }, title);
218+
});
219+
});

0 commit comments

Comments
 (0)