Skip to content

Commit 13b9015

Browse files
authored
Strengthen Emmet tests (microsoft#187204)
1 parent 7061dbd commit 13b9015

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

extensions/emmet/src/test/abbreviationAction.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ const invokeCompletionContext: CompletionContext = {
4747
};
4848

4949
suite('Tests for Expand Abbreviations (HTML)', () => {
50-
const oldValueForExcludeLanguages = workspace.getConfiguration('emmet').inspect('excludeLanguages');
51-
const oldValueForIncludeLanguages = workspace.getConfiguration('emmet').inspect('includeLanguages');
5250
teardown(closeAllEditors);
5351

5452
test('Expand snippets (HTML)', () => {
@@ -364,6 +362,7 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
364362
});
365363

366364
test('Expand html when inside script tag with javascript type if js is mapped to html (HTML)', async () => {
365+
const oldConfig = workspace.getConfiguration('emmet').inspect('includeLanguages')?.globalValue;
367366
await workspace.getConfiguration('emmet').update('includeLanguages', { 'javascript': 'html' }, ConfigurationTarget.Global);
368367
await withRandomFileEditor(htmlContents, 'html', async (editor, _doc) => {
369368
editor.selection = new Selection(24, 10, 24, 10);
@@ -374,12 +373,13 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
374373
await expandPromise;
375374
assert.strictEqual(editor.document.getText(), htmlContents.replace('span.bye', '<span class="bye"></span>'));
376375
});
377-
return workspace.getConfiguration('emmet').update('includeLanguages', oldValueForIncludeLanguages || {}, ConfigurationTarget.Global);
376+
await workspace.getConfiguration('emmet').update('includeLanguages', oldConfig, ConfigurationTarget.Global);
378377
});
379378

380379
test('Expand html in completion list when inside script tag with javascript type if js is mapped to html (HTML)', async () => {
381380
const abbreviation = 'span.bye';
382381
const expandedText = '<span class="bye"></span>';
382+
const oldConfig = workspace.getConfiguration('emmet').inspect('includeLanguages')?.globalValue;
383383
await workspace.getConfiguration('emmet').update('includeLanguages', { 'javascript': 'html' }, ConfigurationTarget.Global);
384384
await withRandomFileEditor(htmlContents, 'html', async (editor, _doc) => {
385385
editor.selection = new Selection(24, 10, 24, 10);
@@ -399,7 +399,7 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
399399
assert.strictEqual(((<string>emmetCompletionItem.documentation) || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
400400
return Promise.resolve();
401401
});
402-
return workspace.getConfiguration('emmet').update('includeLanguages', oldValueForIncludeLanguages || {}, ConfigurationTarget.Global);
402+
await workspace.getConfiguration('emmet').update('includeLanguages', oldConfig, ConfigurationTarget.Global);
403403
});
404404

405405
// test('No expanding when html is excluded in the settings', () => {
@@ -411,9 +411,10 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
411411
// });
412412

413413
test('No expanding when html is excluded in the settings in completion list', async () => {
414+
const oldConfig = workspace.getConfiguration('emmet').inspect('excludeLanguages')?.globalValue;
414415
await workspace.getConfiguration('emmet').update('excludeLanguages', ['html'], ConfigurationTarget.Global);
415416
await testHtmlCompletionProvider(new Selection(9, 6, 9, 6), '', '', true);
416-
return workspace.getConfiguration('emmet').update('excludeLanguages', oldValueForExcludeLanguages ? oldValueForExcludeLanguages.globalValue : undefined, ConfigurationTarget.Global);
417+
await workspace.getConfiguration('emmet').update('excludeLanguages', oldConfig, ConfigurationTarget.Global);
417418
});
418419

419420
// test('No expanding when php (mapped syntax) is excluded in the settings', () => {

0 commit comments

Comments
 (0)