Extract joinLines

This commit is contained in:
Matt Bierner
2018-11-29 15:26:01 -08:00
parent 2c2ae49145
commit 06a64b097f

View File

@@ -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'));
));
});
});