Skip to content

Commit 98e653e

Browse files
committed
Add tests for deducing extension kind
1 parent fd91d44 commit 98e653e

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

src/vs/workbench/services/extensions/common/extensionsUtil.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export function getExtensionKind(manifest: IExtensionManifest, productService: I
5959
return toArray(result);
6060
}
6161

62+
return deduceExtensionKind(manifest);
63+
}
64+
65+
export function deduceExtensionKind(manifest: IExtensionManifest): ExtensionKind[] {
6266
// Not an UI extension if it has main
6367
if (manifest.main) {
6468
if (manifest.browser) {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as assert from 'assert';
7+
import { deduceExtensionKind } from 'vs/workbench/services/extensions/common/extensionsUtil';
8+
import { IExtensionManifest, ExtensionKind } from 'vs/platform/extensions/common/extensions';
9+
10+
suite('ExtensionKind', () => {
11+
12+
function check(manifest: Partial<IExtensionManifest>, expected: ExtensionKind[]): void {
13+
assert.deepEqual(deduceExtensionKind(<IExtensionManifest>manifest), expected);
14+
}
15+
16+
test('declarative with extension dependencies => workspace', () => {
17+
check({ extensionDependencies: ['ext1'] }, ['workspace']);
18+
});
19+
20+
test('declarative extension pack => workspace', () => {
21+
check({ extensionPack: ['ext1', 'ext2'] }, ['workspace']);
22+
});
23+
24+
test('declarative with unknown contribution point => workspace', () => {
25+
check({ contributes: <any>{ 'unknownPoint': { something: true } } }, ['workspace']);
26+
});
27+
28+
test('simple declarative => ui, workspace, web', () => {
29+
check({}, ['ui', 'workspace', 'web']);
30+
});
31+
32+
test('only browser => web', () => {
33+
check({ browser: 'main.browser.js' }, ['web']);
34+
});
35+
36+
test('only main => workspace', () => {
37+
check({ main: 'main.js' }, ['workspace']);
38+
});
39+
40+
test('main and browser => workspace, web', () => {
41+
check({ main: 'main.js', browser: 'main.browser.js' }, ['workspace', 'web']);
42+
});
43+
});

0 commit comments

Comments
 (0)