Skip to content

Commit 318a853

Browse files
committed
Update unit tests to new input type
1 parent 41cdf8e commit 318a853

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

src/test/emmetHelper.test.ts

+43-43
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { FileService, FileType } from '../fileService';
1010
import { URI } from 'vscode-uri';
1111
import { ExtractOptions } from 'emmet';
1212

13-
const extensionsPath = path.join(path.normalize(path.join(__dirname, '../../..')), 'testData', 'custom-snippets-profile');
13+
const extensionsPath = [path.join(path.normalize(path.join(__dirname, '../../..')), 'testData', 'custom-snippets-profile')];
1414
const bemFilterExample = 'ul.search-form._wide>li.-querystring+li.-btn_large';
1515
const expectedBemFilterOutput =
1616
`<ul class="search-form search-form_wide">
@@ -77,7 +77,7 @@ const fileService: FileService = {
7777
}
7878
}
7979

80-
function updateExtensionsPath(extPath: string | string[]): Promise<void> {
80+
function updateExtensionsPath(extPath: string[]): Promise<void> {
8181
return updateExtensionsPathHelper(extPath, fileService, URI.file('/home/projects/test'))
8282
}
8383

@@ -366,7 +366,7 @@ describe('Test variables settings', () => {
366366
describe('Test custom snippets', () => {
367367
it('should use custom snippets for given syntax from extensionsPath', async () => {
368368
const customSnippetKey = 'ch';
369-
await updateExtensionsPath(null);
369+
await updateExtensionsPath([]);
370370
const expandOptionsWithoutCustomSnippets = getExpandOptions('css');
371371
assert(!expandOptionsWithoutCustomSnippets.snippets);
372372

@@ -380,7 +380,7 @@ describe('Test custom snippets', () => {
380380
it('should use custom snippets inherited from base syntax from extensionsPath', async () => {
381381
const customSnippetKey = 'ch';
382382

383-
await updateExtensionsPath(null);
383+
await updateExtensionsPath([]);
384384
const expandOptionsWithoutCustomSnippets = getExpandOptions('scss');
385385
assert(!expandOptionsWithoutCustomSnippets.snippets);
386386

@@ -396,12 +396,12 @@ describe('Test custom snippets', () => {
396396

397397
it('should use custom snippets for given syntax in the absence of base syntax from extensionsPath', async () => {
398398
const customSnippetKey = 'ch';
399-
await updateExtensionsPath(null);
399+
await updateExtensionsPath([]);
400400
const expandOptionsWithoutCustomSnippets = getExpandOptions('scss');
401401
assert(!expandOptionsWithoutCustomSnippets.snippets);
402402

403403
// Use custom snippets from extensionsPath
404-
await updateExtensionsPath(path.join(path.normalize(path.join(__dirname, '../../..')), 'testData', 'custom-snippets-without-inheritence'));
404+
await updateExtensionsPath([path.join(path.normalize(path.join(__dirname, '../../..')), 'testData', 'custom-snippets-without-inheritence')]);
405405
const expandOptionsWithCustomSnippets = getExpandOptions('scss');
406406

407407
assert.strictEqual(Object.keys(expandOptionsWithCustomSnippets.snippets).some(key => key === customSnippetKey), true);
@@ -410,7 +410,7 @@ describe('Test custom snippets', () => {
410410
it('should throw error when snippets file from extensionsPath has invalid json', async () => {
411411
const invalidJsonPath = path.join(path.normalize(path.join(__dirname, '../../..')), 'testData', 'custom-snippets-invalid-json');
412412
try {
413-
await updateExtensionsPath(invalidJsonPath);
413+
await updateExtensionsPath([invalidJsonPath]);
414414
return Promise.reject('There should be an error as snippets file contained invalid json');
415415
} catch (e) {
416416
assert.ok(e);
@@ -422,7 +422,7 @@ describe('Test custom snippets', () => {
422422
await updateExtensionsPath(extensionsPath);
423423
assert.strictEqual(Object.keys(getExpandOptions('scss').snippets).some(key => key === customSnippetKey), true);
424424

425-
await updateExtensionsPath(null);
425+
await updateExtensionsPath([]);
426426
assert.ok(!getExpandOptions('scss').snippets, 'There should be no custom snippets as extensionPath was not given');
427427
});
428428

@@ -432,7 +432,7 @@ describe('Test custom snippets', () => {
432432
assert.strictEqual(Object.keys(getExpandOptions('scss').snippets).some(key => key === customSnippetKey), true);
433433

434434
try {
435-
await updateExtensionsPath(extensionsPath + 'path');
435+
await updateExtensionsPath(["./this/is/not/valid"]);
436436
return Promise.reject('There should be an error as extensionPath was faulty');
437437
} catch (e) {
438438
assert.ok(!getExpandOptions('scss').snippets, 'There should be no custom snippets as extensionPath was faulty');
@@ -449,7 +449,7 @@ describe('Test custom snippets', () => {
449449

450450
const extensionsPathParent = path.join(path.normalize(path.join(__dirname, '../../..')), 'testData');
451451
try {
452-
await updateExtensionsPath(extensionsPathParent);
452+
await updateExtensionsPath([extensionsPathParent]);
453453
return Promise.reject('There should be an error as extensionPath was faulty');
454454
} catch (e) {
455455
assert.ok(!getExpandOptions('scss').snippets, 'There should be no custom snippets as extensionPath was faulty');
@@ -459,12 +459,12 @@ describe('Test custom snippets', () => {
459459
// https://github.com/microsoft/vscode/issues/116741
460460
it('should use the first valid custom snippets from an array of extensions path', async () => {
461461
const customSnippetKey = 'ch';
462-
await updateExtensionsPath(null);
462+
await updateExtensionsPath([]);
463463
const expandOptionsWithoutCustomSnippets = getExpandOptions('css');
464464
assert(!expandOptionsWithoutCustomSnippets.snippets);
465465

466466
// Use custom snippets from extensionsPathArray
467-
const extensionsPathArray = ["./this/is/not/valid", extensionsPath]
467+
const extensionsPathArray = ["./this/is/not/valid", extensionsPath[0]]
468468
await updateExtensionsPath(extensionsPathArray);
469469
const expandOptionsWithCustomSnippets = getExpandOptions('css');
470470

@@ -495,29 +495,29 @@ describe('Test emmet preferences', () => {
495495

496496
describe('Test filters (bem and comment)', () => {
497497
it('should expand haml', async () => {
498-
await updateExtensionsPath(null);
498+
await updateExtensionsPath([]);
499499
assert.strictEqual(expandAbbreviation('ul[data="class"]', getExpandOptions('haml', {})), '%ul(data="class") ${0}');
500500
});
501501

502502
it('should expand attributes with []', async () => {
503-
await updateExtensionsPath(null);
503+
await updateExtensionsPath([]);
504504
assert.strictEqual(expandAbbreviation('div[[a]="b"]', getExpandOptions('html', {})), '<div [a]="b">${0}</div>');
505505
});
506506

507507
it('should expand abbreviations that are nodes with no name', async () => {
508-
await updateExtensionsPath(null);
508+
await updateExtensionsPath([]);
509509
assert.strictEqual(expandAbbreviation('c', getExpandOptions('html', {})), '<!-- ${0} -->');
510510
});
511511

512512
it('should use filters from expandOptions', async () => {
513-
await updateExtensionsPath(null);
513+
await updateExtensionsPath([]);
514514
assert.strictEqual(expandAbbreviation(bemFilterExample, getExpandOptions('html', {}, 'bem')), expectedBemFilterOutput);
515515
assert.strictEqual(expandAbbreviation(commentFilterExample, getExpandOptions('html', {}, 'c')), expectedCommentFilterOutput);
516516
assert.strictEqual(expandAbbreviation(bemCommentFilterExample, getExpandOptions('html', {}, 'bem,c')), expectedBemCommentFilterOutput);
517517
});
518518

519519
it('should use filters from syntaxProfiles', async () => {
520-
await updateExtensionsPath(null);
520+
await updateExtensionsPath([]);
521521
assert.strictEqual(expandAbbreviation(bemFilterExample, getExpandOptions('html', {
522522
syntaxProfiles: {
523523
html: {
@@ -537,7 +537,7 @@ describe('Test filters (bem and comment)', () => {
537537

538538
describe('Test completions', () => {
539539
it('should provide multiple common tags completions in html', async () => {
540-
await updateExtensionsPath(null);
540+
await updateExtensionsPath([]);
541541
const document = TextDocument.create('test://test/test.html', 'html', 0, 'd');
542542
const position = Position.create(0, 1);
543543
const completionList = doComplete(document, position, 'html', {
@@ -553,7 +553,7 @@ describe('Test completions', () => {
553553
});
554554

555555
it('should provide multiple snippet suggestions in html', async () => {
556-
await updateExtensionsPath(null);
556+
await updateExtensionsPath([]);
557557
const document = TextDocument.create('test://test/test.html', 'html', 0, 'a:');
558558
const position = Position.create(0, 2);
559559
const completionList = doComplete(document, position, 'html', {
@@ -569,7 +569,7 @@ describe('Test completions', () => {
569569
});
570570

571571
it('should not provide any suggestions in html for class names or id', async () => {
572-
await updateExtensionsPath(null);
572+
await updateExtensionsPath([]);
573573
const testCases = ['div.col', 'div#col'];
574574
testCases.forEach(abbr => {
575575
const document = TextDocument.create('test://test/test.html', 'html', 0, abbr);
@@ -587,7 +587,7 @@ describe('Test completions', () => {
587587
});
588588

589589
it('should provide multiple snippet suggestions in html for nested abbreviations', async () => {
590-
await updateExtensionsPath(null);
590+
await updateExtensionsPath([]);
591591
const testCases = ['ul>a:', 'ul+a:'];
592592
testCases.forEach(abbr => {
593593
const document = TextDocument.create('test://test/test.html', 'html', 0, abbr);
@@ -607,7 +607,7 @@ describe('Test completions', () => {
607607

608608
it('should not provide link:m as a suggestion', async () => {
609609
// https://github.com/microsoft/vscode/issues/66680
610-
await updateExtensionsPath(null);
610+
await updateExtensionsPath([]);
611611
const abbr = 'link:m';
612612
const document = TextDocument.create('test://test/test.html', 'html', 0, abbr);
613613
const position = Position.create(0, abbr.length);
@@ -624,7 +624,7 @@ describe('Test completions', () => {
624624

625625
it('should not provide marginright as a suggestion SCSS', async () => {
626626
// https://github.com/microsoft/vscode-emmet-helper/issues/42
627-
await updateExtensionsPath(null);
627+
await updateExtensionsPath([]);
628628
const abbr = 'marginright';
629629
const document = TextDocument.create('test://test/test.scss', 'scss', 0, abbr);
630630
const position = Position.create(0, abbr.length);
@@ -640,7 +640,7 @@ describe('Test completions', () => {
640640
});
641641

642642
it('should provide completions html', async () => {
643-
await updateExtensionsPath(null);
643+
await updateExtensionsPath([]);
644644
const bemFilterExampleWithInlineFilter = bemFilterExample + '|bem';
645645
const commentFilterExampleWithInlineFilter = commentFilterExample + '|c';
646646
const bemCommentFilterExampleWithInlineFilter = bemCommentFilterExample + '|bem|c';
@@ -682,7 +682,7 @@ describe('Test completions', () => {
682682
});
683683

684684
it('should provide completions css', async () => {
685-
await updateExtensionsPath(null);
685+
await updateExtensionsPath([]);
686686
const testCases: [string, string][] = [
687687
['trf', 'transform: ;'],
688688
['trf:rx', 'transform: rotateX(angle);'],
@@ -712,7 +712,7 @@ describe('Test completions', () => {
712712

713713
it('should not provide html completions for xml', async () => {
714714
// https://github.com/microsoft/vscode/issues/97632
715-
await updateExtensionsPath(null);
715+
await updateExtensionsPath([]);
716716
const testCases: string[] = ['a', 'bo', 'body'];
717717
const positionLine = 0;
718718
testCases.forEach(abbreviation => {
@@ -731,7 +731,7 @@ describe('Test completions', () => {
731731
});
732732

733733
it('should provide hex color completions css', async () => {
734-
await updateExtensionsPath(null);
734+
await updateExtensionsPath([]);
735735
const testCases: [string, string][] = [
736736
['#1', '#111'],
737737
['#ab', '#ababab'],
@@ -759,7 +759,7 @@ describe('Test completions', () => {
759759
});
760760

761761
it.skip('should provide empty incomplete completion list for abbreviations that just have the vendor prefix', async () => {
762-
await updateExtensionsPath(null);
762+
await updateExtensionsPath([]);
763763
const testCases: [string, number, number][] = [
764764
['-', 0, 1],
765765
['-m-', 0, 3],
@@ -787,7 +787,7 @@ describe('Test completions', () => {
787787
})
788788

789789
it('should provide completions for text that are prefix for snippets, ensure $ doesnt get escaped', async () => {
790-
await updateExtensionsPath(null);
790+
await updateExtensionsPath([]);
791791
const testCases: [string, number, number][] = [
792792
['<div> l </div>', 0, 7]
793793
];
@@ -811,7 +811,7 @@ describe('Test completions', () => {
811811
});
812812

813813
it('should provide completions for scss', async () => {
814-
await updateExtensionsPath(null);
814+
await updateExtensionsPath([]);
815815
const testCases: [string, number, number][] = [
816816
['m:a', 0, 3]
817817
];
@@ -831,7 +831,7 @@ describe('Test completions', () => {
831831
});
832832

833833
it('should provide completions with escaped $ in scss', async () => {
834-
await updateExtensionsPath(null);
834+
await updateExtensionsPath([]);
835835
const testCases: [string, number, number][] = [
836836
['bgi$hello', 0, 9]
837837
];
@@ -852,7 +852,7 @@ describe('Test completions', () => {
852852
});
853853

854854
it('should provide completions with escaped $ in html', async () => {
855-
await updateExtensionsPath(null);
855+
await updateExtensionsPath([]);
856856
const testCases: [string, number, number, string, string][] = [
857857
['span{\\$5}', 0, 9, '<span>$5</span>', '<span>\\$5</span>'],
858858
['span{\\$hello}', 0, 13, '<span>$hello</span>', '<span>\\$hello</span>']
@@ -948,7 +948,7 @@ describe('Test completions', () => {
948948
});
949949

950950
it('should not provide completions as they would noise when typing (html)', async () => {
951-
await updateExtensionsPath(null);
951+
await updateExtensionsPath([]);
952952
const testCases: [string, number, number][] = [
953953
['<div>abc</div>', 0, 8],
954954
['<div>Abc</div>', 0, 8],
@@ -977,7 +977,7 @@ describe('Test completions', () => {
977977
});
978978

979979
it('should provide completions for pascal-case tags when typing (jsx)', async () => {
980-
await updateExtensionsPath(null);
980+
await updateExtensionsPath([]);
981981
const testCases: [string, number, number, string, string][] = [
982982
['<div>Router</div>', 0, 11, 'Router', '<Router>|</Router>', ],
983983
['<div>MyAwesomeComponent</div>', 0, 23, 'MyAwesomeComponent', '<MyAwesomeComponent>|</MyAwesomeComponent>'],
@@ -999,7 +999,7 @@ describe('Test completions', () => {
999999
})
10001000

10011001
it('should not provide completions as they would noise when typing (css)', async () => {
1002-
await updateExtensionsPath(null);
1002+
await updateExtensionsPath([]);
10031003
const testCases: [string, number, number][] = [
10041004
['background', 0, 10],
10051005
['font-family', 0, 11],
@@ -1023,7 +1023,7 @@ describe('Test completions', () => {
10231023
});
10241024

10251025
it('should provide completions for loremn with n words', async () => {
1026-
await updateExtensionsPath(null);
1026+
await updateExtensionsPath([]);
10271027
const document = TextDocument.create('test://test/test.html', 'html', 0, '.item>lorem10');
10281028
const position = Position.create(0, 13);
10291029
const completionList = doComplete(document, position, 'html', {
@@ -1046,7 +1046,7 @@ describe('Test completions', () => {
10461046
});
10471047

10481048
it('should provide completions for lorem*n with n lines', async () => {
1049-
await updateExtensionsPath(null);
1049+
await updateExtensionsPath([]);
10501050
const document = TextDocument.create('test://test/test.html', 'html', 0, 'lorem*3');
10511051
const position = Position.create(0, 12);
10521052
const completionList = doComplete(document, position, 'html', {
@@ -1068,7 +1068,7 @@ describe('Test completions', () => {
10681068

10691069
it('should provide completions for lorem*2 with 2 lines', async () => {
10701070
// https://github.com/microsoft/vscode/issues/52345
1071-
await updateExtensionsPath(null);
1071+
await updateExtensionsPath([]);
10721072
const document = TextDocument.create('test://test/test.html', 'html', 0, 'lorem*2');
10731073
const position = Position.create(0, 12);
10741074
const completionList = doComplete(document, position, 'html', {
@@ -1150,7 +1150,7 @@ describe('Test completions', () => {
11501150
});
11511151

11521152
it.skip('should expand with multiple vendor prefixes', async () => {
1153-
await updateExtensionsPath(null);
1153+
await updateExtensionsPath([]);
11541154
assert.strictEqual(expandAbbreviation('brs', getExpandOptions('css', {})), 'border-radius: ${0};');
11551155
assert.strictEqual(expandAbbreviation('brs5', getExpandOptions('css', {})), 'border-radius: 5px;');
11561156
assert.strictEqual(expandAbbreviation('brs10px', getExpandOptions('css', {})), 'border-radius: 10px;');
@@ -1164,15 +1164,15 @@ describe('Test completions', () => {
11641164
});
11651165

11661166
it.skip('should expand with default vendor prefixes in properties', async () => {
1167-
await updateExtensionsPath(null);
1167+
await updateExtensionsPath([]);
11681168
assert.strictEqual(expandAbbreviation('-p', getExpandOptions('css', { preferences: { 'css.webkitProperties': 'foo, bar, padding' } })), '-webkit-padding: ${0};\npadding: ${0};');
11691169
assert.strictEqual(expandAbbreviation('-p', getExpandOptions('css', { preferences: { 'css.oProperties': 'padding', 'css.webkitProperties': 'padding' } })), '-webkit-padding: ${0};\n-o-padding: ${0};\npadding: ${0};');
11701170
assert.strictEqual(expandAbbreviation('-brs', getExpandOptions('css', { preferences: { 'css.oProperties': 'padding', 'css.webkitProperties': 'padding', 'css.mozProperties': '', 'css.msProperties': '' } })), '-webkit-border-radius: ${0};\n-moz-border-radius: ${0};\n-ms-border-radius: ${0};\n-o-border-radius: ${0};\nborder-radius: ${0};');
11711171
assert.strictEqual(expandAbbreviation('-o-p', getExpandOptions('css', { preferences: { 'css.oProperties': 'padding', 'css.webkitProperties': 'padding' } })), '-o-padding: ${0};\npadding: ${0};');
11721172
});
11731173

11741174
it('should not provide completions for excludedLanguages', async () => {
1175-
await updateExtensionsPath(null);
1175+
await updateExtensionsPath([]);
11761176
const document = TextDocument.create('test://test/test.html', 'html', 0, 'ul>li');
11771177
const position = Position.create(0, 5);
11781178
const completionList = doComplete(document, position, 'html', {
@@ -1188,7 +1188,7 @@ describe('Test completions', () => {
11881188
});
11891189

11901190
it('should provide completions with kind snippet when showSuggestionsAsSnippets is enabled', async () => {
1191-
await updateExtensionsPath(null);
1191+
await updateExtensionsPath([]);
11921192
const document = TextDocument.create('test://test/test.html', 'html', 0, 'ul>li');
11931193
const position = Position.create(0, 5);
11941194
const completionList = doComplete(document, position, 'html', {
@@ -1204,7 +1204,7 @@ describe('Test completions', () => {
12041204
});
12051205

12061206
it('should not provide double completions for commonly used tags that are also snippets', async () => {
1207-
await updateExtensionsPath(null);
1207+
await updateExtensionsPath([]);
12081208
const document = TextDocument.create('test://test/test.html', 'html', 0, 'abb');
12091209
const position = Position.create(0, 3);
12101210
const completionList = doComplete(document, position, 'html', {

0 commit comments

Comments
 (0)