Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/test/vscode-node/extension.test.ts
13399 views
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 assert from 'assert';
7
import { ExtensionContext, ExtensionMode, Memento } from 'vscode';
8
import { IDisposable } from '../../../util/vs/base/common/lifecycle';
9
import { vscodeNodeContributions } from '../../extension/vscode-node/contributions';
10
import { registerServices } from '../../extension/vscode-node/services';
11
import { createInstantiationService } from '../../extension/vscode/extension';
12
13
suite('Extension tests', function () {
14
let disposables: IDisposable[] = [];
15
16
teardown(() => {
17
disposables.forEach(d => d.dispose());
18
disposables = [];
19
});
20
21
test('can create production context', async function () {
22
const globalState: Memento = {
23
get: () => undefined,
24
update: () => Promise.resolve(),
25
keys: () => [],
26
};
27
const extensionContext = {
28
extensionMode: ExtensionMode.Production,
29
extension: {
30
packageJSON: {
31
name: 'copilot',
32
},
33
},
34
globalState,
35
subscriptions: [] as { dispose(): any }[],
36
} as ExtensionContext;
37
const accessor = createInstantiationService({
38
context: extensionContext,
39
contributions: vscodeNodeContributions,
40
registerServices
41
});
42
disposables.push(accessor);
43
assert.ok(accessor);
44
});
45
46
// TODO@lramos15 has to be skipped, when we don't have a token, because
47
// of the eventual call to `getOrCreateTestingCopilotTokenManager` which
48
// requires a token in a sync fashion.
49
test.skip('can create test context', async function () {
50
const extensionContext = {
51
extensionMode: ExtensionMode.Test,
52
subscriptions: [] as { dispose(): any }[],
53
extension: {
54
id: 'copilot.extension-test',
55
packageJSON: {},
56
},
57
} as ExtensionContext;
58
const accessor = createInstantiationService({
59
context: extensionContext,
60
contributions: vscodeNodeContributions,
61
registerServices
62
});
63
disposables.push(accessor);
64
assert.ok(accessor);
65
});
66
});
67
68