diff --git a/extensions/emmet/src/test/abbreviationAction.test.ts b/extensions/emmet/src/test/abbreviationAction.test.ts
index af7dbbdba1e8b5e45fcd15385376ead0c6a197bc..b222ecf5fe5dc5468f4b2255187452988f0db402 100644
--- a/extensions/emmet/src/test/abbreviationAction.test.ts
+++ b/extensions/emmet/src/test/abbreviationAction.test.ts
@@ -58,17 +58,16 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
test('Expand snippets when no parent node (HTML)', () => {
- return withRandomFileEditor('img', 'html', (editor, doc) => {
+ return withRandomFileEditor('img', 'html', async (editor, doc) => {
editor.selection = new Selection(0, 3, 0, 3);
- return expandEmmetAbbreviation(null).then(() => {
- assert.equal(editor.document.getText(), '');
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation(null);
+ assert.equal(editor.document.getText(), '');
+ return Promise.resolve();
});
});
test('Expand snippets when no parent node in completion list (HTML)', () => {
- return withRandomFileEditor('img', 'html', (editor, doc) => {
+ return withRandomFileEditor('img', 'html', async (editor, doc) => {
editor.selection = new Selection(0, 3, 0, 3);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -76,14 +75,13 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
assert.equal(!completionPromise, false, `Got unexpected undefined instead of a completion promise`);
return Promise.resolve();
}
- return completionPromise.then(completionList => {
- assert.equal(completionList && completionList.items && completionList.items.length > 0, true);
- if (completionList) {
- assert.equal(completionList.items[0].label, 'img');
- assert.equal((completionList.items[0].documentation || '').replace(/\|/g, ''), '');
- }
- return Promise.resolve();
- });
+ const completionList = await completionPromise;
+ assert.equal(completionList && completionList.items && completionList.items.length > 0, true);
+ if (completionList) {
+ assert.equal(completionList.items[0].label, 'img');
+ assert.equal(((completionList.items[0].documentation) || '').replace(/\|/g, ''), '');
+ }
+ return Promise.resolve();
});
});
@@ -160,12 +158,11 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
test('No expanding text inside open tag (HTML)', () => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(2, 4, 2, 4);
- return expandEmmetAbbreviation(null).then(() => {
- assert.equal(editor.document.getText(), htmlContents);
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation(null);
+ assert.equal(editor.document.getText(), htmlContents);
+ return Promise.resolve();
});
});
@@ -180,12 +177,11 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
test('No expanding text inside open tag when there is no closing tag (HTML)', () => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(9, 8, 9, 8);
- return expandEmmetAbbreviation(null).then(() => {
- assert.equal(editor.document.getText(), htmlContents);
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation(null);
+ assert.equal(editor.document.getText(), htmlContents);
+ return Promise.resolve();
});
});
@@ -201,12 +197,11 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
test('No expanding text inside open tag when there is no closing tag when there is no parent node (HTML)', () => {
const fileContents = ' {
+ return withRandomFileEditor(fileContents, 'html', async (editor, doc) => {
editor.selection = new Selection(0, 6, 0, 6);
- return expandEmmetAbbreviation(null).then(() => {
- assert.equal(editor.document.getText(), fileContents);
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation(null);
+ assert.equal(editor.document.getText(), fileContents);
+ return Promise.resolve();
});
});
@@ -222,16 +217,15 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
test('Expand css when inside style tag (HTML)', () => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(13, 16, 13, 19);
let expandPromise = expandEmmetAbbreviation({ language: 'css' });
if (!expandPromise) {
return Promise.resolve();
}
- return expandPromise.then(() => {
- assert.equal(editor.document.getText(), htmlContents.replace('m10', 'margin: 10px;'));
- return Promise.resolve();
- });
+ await expandPromise;
+ assert.equal(editor.document.getText(), htmlContents.replace('m10', 'margin: 10px;'));
+ return Promise.resolve();
});
});
@@ -239,7 +233,7 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
const abbreviation = 'm10';
const expandedText = 'margin: 10px;';
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(13, 16, 13, 19);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -248,27 +242,25 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
return Promise.resolve();
}
- return completionPromise.then((completionList: CompletionList) => {
- if (!completionList.items || !completionList.items.length) {
- assert.equal(1, 2, `Problem with expanding m10`);
- return Promise.resolve();
- }
- const emmetCompletionItem = completionList.items[0];
- assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
- assert.equal((emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
- assert.equal(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
+ const completionList = await completionPromise;
+ if (!completionList || !completionList.items || !completionList.items.length) {
+ assert.equal(1, 2, `Problem with expanding m10`);
return Promise.resolve();
- });
+ }
+ const emmetCompletionItem = completionList.items[0];
+ assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
+ assert.equal(((emmetCompletionItem.documentation) || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
+ assert.equal(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
+ return Promise.resolve();
});
});
test('No expanding text inside style tag if position is not for property name (HTML)', () => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(13, 14, 13, 14);
- return expandEmmetAbbreviation(null).then(() => {
- assert.equal(editor.document.getText(), htmlContents);
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation(null);
+ assert.equal(editor.document.getText(), htmlContents);
+ return Promise.resolve();
});
});
@@ -284,16 +276,15 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
test('Expand css when inside style attribute (HTML)', () => {
const styleAttributeContent = '';
- return withRandomFileEditor(styleAttributeContent, 'html', (editor, doc) => {
+ return withRandomFileEditor(styleAttributeContent, 'html', async (editor, doc) => {
editor.selection = new Selection(0, 15, 0, 15);
let expandPromise = expandEmmetAbbreviation(null);
if (!expandPromise) {
return Promise.resolve();
}
- return expandPromise.then(() => {
- assert.equal(editor.document.getText(), styleAttributeContent.replace('m10', 'margin: 10px;'));
- return Promise.resolve();
- });
+ await expandPromise;
+ assert.equal(editor.document.getText(), styleAttributeContent.replace('m10', 'margin: 10px;'));
+ return Promise.resolve();
});
});
@@ -301,7 +292,7 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
const abbreviation = 'm10';
const expandedText = 'margin: 10px;';
- return withRandomFileEditor('', 'html', (editor, doc) => {
+ return withRandomFileEditor('', 'html', async (editor, doc) => {
editor.selection = new Selection(0, 15, 0, 15);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -310,31 +301,29 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
return Promise.resolve();
}
- return completionPromise.then((completionList: CompletionList) => {
- if (!completionList.items || !completionList.items.length) {
- assert.equal(1, 2, `Problem with expanding m10`);
- return Promise.resolve();
- }
- const emmetCompletionItem = completionList.items[0];
- assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
- assert.equal((emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
- assert.equal(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
+ const completionList = await completionPromise;
+ if (!completionList || !completionList.items || !completionList.items.length) {
+ assert.equal(1, 2, `Problem with expanding m10`);
return Promise.resolve();
- });
+ }
+ const emmetCompletionItem = completionList.items[0];
+ assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
+ assert.equal(((emmetCompletionItem.documentation) || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
+ assert.equal(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
+ return Promise.resolve();
});
});
test('Expand html when inside script tag with html type (HTML)', () => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(21, 12, 21, 12);
let expandPromise = expandEmmetAbbreviation(null);
if (!expandPromise) {
return Promise.resolve();
}
- return expandPromise.then(() => {
- assert.equal(editor.document.getText(), htmlContents.replace('span.hello', ''));
- return Promise.resolve();
- });
+ await expandPromise;
+ assert.equal(editor.document.getText(), htmlContents.replace('span.hello', ''));
+ return Promise.resolve();
});
});
@@ -342,7 +331,7 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
const abbreviation = 'span.hello';
const expandedText = '';
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(21, 12, 21, 12);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -351,26 +340,24 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
return Promise.resolve();
}
- return completionPromise.then((completionList: CompletionList) => {
- if (!completionList.items || !completionList.items.length) {
- assert.equal(1, 2, `Problem with expanding span.hello`);
- return Promise.resolve();
- }
- const emmetCompletionItem = completionList.items[0];
- assert.equal(emmetCompletionItem.label, abbreviation, `Label of completion item doesnt match.`);
- assert.equal((emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
+ const completionList = await completionPromise;
+ if (!completionList || !completionList.items || !completionList.items.length) {
+ assert.equal(1, 2, `Problem with expanding span.hello`);
return Promise.resolve();
- });
+ }
+ const emmetCompletionItem = completionList.items[0];
+ assert.equal(emmetCompletionItem.label, abbreviation, `Label of completion item doesnt match.`);
+ assert.equal(((emmetCompletionItem.documentation) || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
+ return Promise.resolve();
});
});
test('No expanding text inside script tag with javascript type (HTML)', () => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = new Selection(24, 12, 24, 12);
- return expandEmmetAbbreviation(null).then(() => {
- assert.equal(editor.document.getText(), htmlContents);
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation(null);
+ assert.equal(editor.document.getText(), htmlContents);
+ return Promise.resolve();
});
});
@@ -384,50 +371,43 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
});
- test('Expand html when inside script tag with javascript type if js is mapped to html (HTML)', () => {
- return workspace.getConfiguration('emmet').update('includeLanguages', {"javascript": "html"}, ConfigurationTarget.Global).then(() => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
- editor.selection = new Selection(24, 10, 24, 10);
- let expandPromise = expandEmmetAbbreviation(null);
- if (!expandPromise) {
- return Promise.resolve();
- }
- return expandPromise.then(() => {
- assert.equal(editor.document.getText(), htmlContents.replace('span.bye', ''));
- });
- }).then(() => {
- return workspace.getConfiguration('emmet').update('includeLanguages', oldValueForInlcudeLanguages || {}, ConfigurationTarget.Global);
- });
+ test('Expand html when inside script tag with javascript type if js is mapped to html (HTML)', async () => {
+ await workspace.getConfiguration('emmet').update('includeLanguages', { "javascript": "html" }, ConfigurationTarget.Global);
+ await withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
+ editor.selection = new Selection(24, 10, 24, 10);
+ let expandPromise = expandEmmetAbbreviation(null);
+ if (!expandPromise) {
+ return Promise.resolve();
+ }
+ await expandPromise;
+ assert.equal(editor.document.getText(), htmlContents.replace('span.bye', ''));
});
+ return workspace.getConfiguration('emmet').update('includeLanguages', oldValueForInlcudeLanguages || {}, ConfigurationTarget.Global);
});
- test('Expand html in completion list when inside script tag with javascript type if js is mapped to html (HTML)', () => {
+ test('Expand html in completion list when inside script tag with javascript type if js is mapped to html (HTML)', async () => {
const abbreviation = 'span.bye';
const expandedText = '';
- return workspace.getConfiguration('emmet').update('includeLanguages', {"javascript": "html"}, ConfigurationTarget.Global).then(() => {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
- editor.selection = new Selection(24, 10, 24, 10);
- const cancelSrc = new CancellationTokenSource();
- const completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
- if (!completionPromise) {
- assert.equal(1, 2, `Problem with expanding span.bye`);
- return Promise.resolve();
- }
-
- return completionPromise.then((completionList: CompletionList) => {
- if (!completionList.items || !completionList.items.length) {
- assert.equal(1, 2, `Problem with expanding span.bye`);
- return Promise.resolve();
- }
- const emmetCompletionItem = completionList.items[0];
- assert.equal(emmetCompletionItem.label, abbreviation, `Label of completion item (${emmetCompletionItem.label}) doesnt match.`);
- assert.equal((emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
- return Promise.resolve();
- });
- }).then(() => {
- return workspace.getConfiguration('emmet').update('includeLanguages', oldValueForInlcudeLanguages || {}, ConfigurationTarget.Global);
- });
+ await workspace.getConfiguration('emmet').update('includeLanguages', { "javascript": "html" }, ConfigurationTarget.Global);
+ await withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
+ editor.selection = new Selection(24, 10, 24, 10);
+ const cancelSrc = new CancellationTokenSource();
+ const completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
+ if (!completionPromise) {
+ assert.equal(1, 2, `Problem with expanding span.bye`);
+ return Promise.resolve();
+ }
+ const completionList = await completionPromise;
+ if (!completionList || !completionList.items || !completionList.items.length) {
+ assert.equal(1, 2, `Problem with expanding span.bye`);
+ return Promise.resolve();
+ }
+ const emmetCompletionItem = completionList.items[0];
+ assert.equal(emmetCompletionItem.label, abbreviation, `Label of completion item (${emmetCompletionItem.label}) doesnt match.`);
+ assert.equal(((emmetCompletionItem.documentation) || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
+ return Promise.resolve();
});
+ return workspace.getConfiguration('emmet').update('includeLanguages', oldValueForInlcudeLanguages || {}, ConfigurationTarget.Global);
});
// test('No expanding when html is excluded in the settings', () => {
@@ -438,12 +418,10 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
// });
// });
- test('No expanding when html is excluded in the settings in completion list', () => {
- return workspace.getConfiguration('emmet').update('excludeLanguages', ['html'], ConfigurationTarget.Global).then(() => {
- return testHtmlCompletionProvider(new Selection(9, 6, 9, 6), '', '', true).then(() => {
- return workspace.getConfiguration('emmet').update('excludeLanguages', oldValueForExcludeLanguages ? oldValueForExcludeLanguages.globalValue : undefined, ConfigurationTarget.Global);
- });
- });
+ test('No expanding when html is excluded in the settings in completion list', async () => {
+ await workspace.getConfiguration('emmet').update('excludeLanguages', ['html'], ConfigurationTarget.Global);
+ await testHtmlCompletionProvider(new Selection(9, 6, 9, 6), '', '', true);
+ return workspace.getConfiguration('emmet').update('excludeLanguages', oldValueForExcludeLanguages ? oldValueForExcludeLanguages.globalValue : undefined, ConfigurationTarget.Global);
});
// test('No expanding when php (mapped syntax) is excluded in the settings', () => {
@@ -462,64 +440,57 @@ suite('Tests for jsx, xml and xsl', () => {
teardown(closeAllEditors);
test('Expand abbreviation with className instead of class in jsx', () => {
- return withRandomFileEditor('ul.nav', 'javascriptreact', (editor, doc) => {
+ return withRandomFileEditor('ul.nav', 'javascriptreact', async (editor, doc) => {
editor.selection = new Selection(0, 6, 0, 6);
- return expandEmmetAbbreviation({ language: 'javascriptreact' }).then(() => {
- assert.equal(editor.document.getText(), '');
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation({ language: 'javascriptreact' });
+ assert.equal(editor.document.getText(), '');
+ return Promise.resolve();
});
});
test('Expand abbreviation with self closing tags for jsx', () => {
- return withRandomFileEditor('img', 'javascriptreact', (editor, doc) => {
+ return withRandomFileEditor('img', 'javascriptreact', async (editor, doc) => {
editor.selection = new Selection(0, 6, 0, 6);
- return expandEmmetAbbreviation({ language: 'javascriptreact' }).then(() => {
- assert.equal(editor.document.getText(), '');
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation({ language: 'javascriptreact' });
+ assert.equal(editor.document.getText(), '');
+ return Promise.resolve();
});
});
- test('Expand abbreviation with single quotes for jsx', () => {
- return workspace.getConfiguration('emmet').update('syntaxProfiles', {jsx: {"attr_quotes": "single"}}, ConfigurationTarget.Global).then(() => {
- return withRandomFileEditor('img', 'javascriptreact', (editor, doc) => {
- editor.selection = new Selection(0, 6, 0, 6);
- return expandEmmetAbbreviation({ language: 'javascriptreact' }).then(() => {
- assert.equal(editor.document.getText(), '');
- return workspace.getConfiguration('emmet').update('syntaxProfiles', oldValueForSyntaxProfiles ? oldValueForSyntaxProfiles.globalValue : undefined, ConfigurationTarget.Global);
- });
- });
+ test('Expand abbreviation with single quotes for jsx', async () => {
+ await workspace.getConfiguration('emmet').update('syntaxProfiles', { jsx: { "attr_quotes": "single" } }, ConfigurationTarget.Global);
+ return withRandomFileEditor('img', 'javascriptreact', async (editor, doc) => {
+ editor.selection = new Selection(0, 6, 0, 6);
+ await expandEmmetAbbreviation({ language: 'javascriptreact' });
+ assert.equal(editor.document.getText(), '');
+ return workspace.getConfiguration('emmet').update('syntaxProfiles', oldValueForSyntaxProfiles ? oldValueForSyntaxProfiles.globalValue : undefined, ConfigurationTarget.Global);
});
});
test('Expand abbreviation with self closing tags for xml', () => {
- return withRandomFileEditor('img', 'xml', (editor, doc) => {
+ return withRandomFileEditor('img', 'xml', async (editor, doc) => {
editor.selection = new Selection(0, 6, 0, 6);
- return expandEmmetAbbreviation({ language: 'xml' }).then(() => {
- assert.equal(editor.document.getText(), '');
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation({ language: 'xml' });
+ assert.equal(editor.document.getText(), '');
+ return Promise.resolve();
});
});
test('Expand abbreviation with no self closing tags for html', () => {
- return withRandomFileEditor('img', 'html', (editor, doc) => {
+ return withRandomFileEditor('img', 'html', async (editor, doc) => {
editor.selection = new Selection(0, 6, 0, 6);
- return expandEmmetAbbreviation({ language: 'html' }).then(() => {
- assert.equal(editor.document.getText(), '');
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation({ language: 'html' });
+ assert.equal(editor.document.getText(), '');
+ return Promise.resolve();
});
});
test('Expand abbreviation with condition containing less than sign for jsx', () => {
- return withRandomFileEditor('if (foo < 10) { span.bar', 'javascriptreact', (editor, doc) => {
+ return withRandomFileEditor('if (foo < 10) { span.bar', 'javascriptreact', async (editor, doc) => {
editor.selection = new Selection(0, 27, 0, 27);
- return expandEmmetAbbreviation({ language: 'javascriptreact' }).then(() => {
- assert.equal(editor.document.getText(), 'if (foo < 10) { ');
- return Promise.resolve();
- });
+ await expandEmmetAbbreviation({ language: 'javascriptreact' });
+ assert.equal(editor.document.getText(), 'if (foo < 10) { ');
+ return Promise.resolve();
});
});
@@ -542,7 +513,7 @@ suite('Tests for jsx, xml and xsl', () => {
});
function testExpandAbbreviation(syntax: string, selection: Selection, abbreviation: string, expandedText: string, shouldFail?: boolean): Thenable {
- return withRandomFileEditor(htmlContents, syntax, (editor, doc) => {
+ return withRandomFileEditor(htmlContents, syntax, async (editor, doc) => {
editor.selection = selection;
let expandPromise = expandEmmetAbbreviation(null);
if (!expandPromise) {
@@ -551,15 +522,14 @@ function testExpandAbbreviation(syntax: string, selection: Selection, abbreviati
}
return Promise.resolve();
}
- return expandPromise.then(() => {
- assert.equal(editor.document.getText(), htmlContents.replace(abbreviation, expandedText));
- return Promise.resolve();
- });
+ await expandPromise;
+ assert.equal(editor.document.getText(), htmlContents.replace(abbreviation, expandedText));
+ return Promise.resolve();
});
}
function testHtmlCompletionProvider(selection: Selection, abbreviation: string, expandedText: string, shouldFail?: boolean): Thenable {
- return withRandomFileEditor(htmlContents, 'html', (editor, doc) => {
+ return withRandomFileEditor(htmlContents, 'html', async (editor, doc) => {
editor.selection = selection;
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
@@ -570,18 +540,17 @@ function testHtmlCompletionProvider(selection: Selection, abbreviation: string,
return Promise.resolve();
}
- return completionPromise.then((completionList: CompletionList) => {
- if (!completionList.items || !completionList.items.length) {
- if (!shouldFail) {
- assert.equal(1, 2, `Problem with expanding ${abbreviation} to ${expandedText}`);
- }
- return Promise.resolve();
+ const completionList = await completionPromise;
+ if (!completionList || !completionList.items || !completionList.items.length) {
+ if (!shouldFail) {
+ assert.equal(1, 2, `Problem with expanding ${abbreviation} to ${expandedText}`);
}
- const emmetCompletionItem = completionList.items[0];
- assert.equal(emmetCompletionItem.label, abbreviation, `Label of completion item doesnt match.`);
- assert.equal((emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
return Promise.resolve();
- });
+ }
+ const emmetCompletionItem = completionList.items[0];
+ assert.equal(emmetCompletionItem.label, abbreviation, `Label of completion item doesnt match.`);
+ assert.equal(((emmetCompletionItem.documentation) || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
+ return Promise.resolve();
});
}