Path: blob/main/extensions/copilot/src/extension/test/vscode-node/extension.test.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { ExtensionContext, ExtensionMode, Memento } from 'vscode';7import { IDisposable } from '../../../util/vs/base/common/lifecycle';8import { vscodeNodeContributions } from '../../extension/vscode-node/contributions';9import { registerServices } from '../../extension/vscode-node/services';10import { createInstantiationService } from '../../extension/vscode/extension';1112suite('Extension tests', function () {13let disposables: IDisposable[] = [];1415teardown(() => {16disposables.forEach(d => d.dispose());17disposables = [];18});1920test('can create production context', async function () {21const globalState: Memento = {22get: () => undefined,23update: () => Promise.resolve(),24keys: () => [],25};26const extensionContext = {27extensionMode: ExtensionMode.Production,28extension: {29packageJSON: {30name: 'copilot',31},32},33globalState,34subscriptions: [] as { dispose(): any }[],35} as ExtensionContext;36const accessor = createInstantiationService({37context: extensionContext,38contributions: vscodeNodeContributions,39registerServices40});41disposables.push(accessor);42assert.ok(accessor);43});4445// TODO@lramos15 has to be skipped, when we don't have a token, because46// of the eventual call to `getOrCreateTestingCopilotTokenManager` which47// requires a token in a sync fashion.48test.skip('can create test context', async function () {49const extensionContext = {50extensionMode: ExtensionMode.Test,51subscriptions: [] as { dispose(): any }[],52extension: {53id: 'copilot.extension-test',54packageJSON: {},55},56} as ExtensionContext;57const accessor = createInstantiationService({58context: extensionContext,59contributions: vscodeNodeContributions,60registerServices61});62disposables.push(accessor);63assert.ok(accessor);64});65});666768