mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 19:59:37 +00:00
Extract joinLines
This commit is contained in:
@@ -7,6 +7,8 @@ import * as assert from 'assert';
|
||||
import 'mocha';
|
||||
import { templateToSnippet } from '../features/jsDocCompletions';
|
||||
|
||||
const joinLines = (...args: string[]) => args.join('\n');
|
||||
|
||||
suite('typescript.jsDocSnippet', () => {
|
||||
test('Should do nothing for single line input', async () => {
|
||||
const input = `/** */`;
|
||||
@@ -15,63 +17,63 @@ suite('typescript.jsDocSnippet', () => {
|
||||
|
||||
test('Should put cursor inside multiline line input', async () => {
|
||||
assert.strictEqual(
|
||||
templateToSnippet([
|
||||
templateToSnippet(joinLines(
|
||||
'/**',
|
||||
' * ',
|
||||
' */'
|
||||
].join('\n')).value,
|
||||
[
|
||||
)).value,
|
||||
joinLines(
|
||||
'/**',
|
||||
' * $0',
|
||||
' */'
|
||||
].join('\n'));
|
||||
));
|
||||
});
|
||||
|
||||
test('Should add placeholders after each parameter', async () => {
|
||||
assert.strictEqual(
|
||||
templateToSnippet([
|
||||
templateToSnippet(joinLines(
|
||||
'/**',
|
||||
' * @param a',
|
||||
' * @param b',
|
||||
' */'
|
||||
].join('\n')).value,
|
||||
[
|
||||
)).value,
|
||||
joinLines(
|
||||
'/**',
|
||||
' * @param a ${1}',
|
||||
' * @param b ${2}',
|
||||
' */'
|
||||
].join('\n'));
|
||||
));
|
||||
});
|
||||
|
||||
test('Should add placeholders for types', async () => {
|
||||
assert.strictEqual(
|
||||
templateToSnippet([
|
||||
templateToSnippet(joinLines(
|
||||
'/**',
|
||||
' * @param {*} a',
|
||||
' * @param {*} b',
|
||||
' */'
|
||||
].join('\n')).value,
|
||||
[
|
||||
)).value,
|
||||
joinLines(
|
||||
'/**',
|
||||
' * @param {${1:*}} a ${2}',
|
||||
' * @param {${3:*}} b ${4}',
|
||||
' */'
|
||||
].join('\n'));
|
||||
));
|
||||
});
|
||||
|
||||
test('Should properly escape dollars in parameter names', async () => {
|
||||
assert.strictEqual(
|
||||
templateToSnippet([
|
||||
templateToSnippet(joinLines(
|
||||
'/**',
|
||||
' * ',
|
||||
' * @param $arg',
|
||||
' */'
|
||||
].join('\n')).value,
|
||||
[
|
||||
)).value,
|
||||
joinLines(
|
||||
'/**',
|
||||
' * $0',
|
||||
' * @param \\$arg ${1}',
|
||||
' */'
|
||||
].join('\n'));
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user