Adding more pinning tests for JS/TS completions

This commit is contained in:
Matt Bierner
2020-02-04 15:47:37 -08:00
parent 9887559f17
commit 7b754d7d95

View File

@@ -267,7 +267,7 @@ suite('TypeScript Completions', () => {
));
});
test('should not de-prioritize this.member suggestion, #74164', async () => {
test('should not de-prioritize `this.member` suggestion, #74164', async () => {
await enumerateConfig(Config.insertMode, insertModes, async config => {
await createTestEditor(testDocumentUri,
`class A {`,
@@ -293,6 +293,32 @@ suite('TypeScript Completions', () => {
});
});
test('Member completions for string properties should insert `this.` and use brackets', async () => {
await enumerateConfig(Config.insertMode, insertModes, async config => {
await createTestEditor(testDocumentUri,
`class A {`,
` ['xyz 123'] = 1`,
` foo() {`,
` xyz$0`,
` }`,
`}`,
);
const document = await acceptFirstSuggestion(testDocumentUri, _disposables);
assert.strictEqual(
document.getText(),
joinLines(
`class A {`,
` ['xyz 123'] = 1`,
` foo() {`,
` this["xyz 123"]`,
` }`,
`}`,
),
`Config: ${config}`);
});
});
test('Accepting a completion in word using insert mode should insert', async () => {
await updateConfig({ [Config.insertMode]: 'insert' });
@@ -327,6 +353,56 @@ suite('TypeScript Completions', () => {
));
});
test('Accepting a member completion in word using insert mode add `this.` and insert', async () => {
await updateConfig({ [Config.insertMode]: 'insert' });
await createTestEditor(testDocumentUri,
`class Foo {`,
` abc = 1;`,
` foo() {`,
` ab$0c`,
` }`,
`}`,
);
const document = await acceptFirstSuggestion(testDocumentUri, _disposables);
assert.strictEqual(
document.getText(),
joinLines(
`class Foo {`,
` abc = 1;`,
` foo() {`,
` this.abcc`,
` }`,
`}`,
));
});
test('Accepting a member completion in word using replace mode should add `this.` and replace', async () => {
await updateConfig({ [Config.insertMode]: 'replace' });
await createTestEditor(testDocumentUri,
`class Foo {`,
` abc = 1;`,
` foo() {`,
` ab$0c`,
` }`,
`}`,
);
const document = await acceptFirstSuggestion(testDocumentUri, _disposables);
assert.strictEqual(
document.getText(),
joinLines(
`class Foo {`,
` abc = 1;`,
` foo() {`,
` this.abc`,
` }`,
`}`,
));
});
test('Accepting string completion inside string using insert mode should insert', async () => {
await updateConfig({ [Config.insertMode]: 'insert' });