From b65016870407ad3b4beae2c1fdb376cf578ddf01 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 13 Dec 2019 14:08:01 -0800 Subject: [PATCH] Add de viewlet tests back (#8673) --- .../test/browser/dataExplorerViewlet.test.ts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/sql/workbench/contrib/dataExplorer/test/browser/dataExplorerViewlet.test.ts diff --git a/src/sql/workbench/contrib/dataExplorer/test/browser/dataExplorerViewlet.test.ts b/src/sql/workbench/contrib/dataExplorer/test/browser/dataExplorerViewlet.test.ts new file mode 100644 index 0000000000..29de3cbd07 --- /dev/null +++ b/src/sql/workbench/contrib/dataExplorer/test/browser/dataExplorerViewlet.test.ts @@ -0,0 +1,55 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as assert from 'assert'; +import * as Platform from 'vs/platform/registry/common/platform'; +import { ViewletDescriptor, Extensions, Viewlet, ViewletRegistry } from 'vs/workbench/browser/viewlet'; +import * as Types from 'vs/base/common/types'; + +suite('Data Explorer Viewlet', () => { + + class DataExplorerTestViewlet extends Viewlet { + + constructor() { + super('dataExplorer', undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined); + } + + public layout(dimension: any): void { + throw new Error('Method not implemented.'); + } + } + + test('ViewletDescriptor API', function () { + let d = ViewletDescriptor.create(DataExplorerTestViewlet, 'id', 'name', 'class', 1); + assert.strictEqual(d.id, 'id'); + assert.strictEqual(d.name, 'name'); + assert.strictEqual(d.cssClass, 'class'); + assert.strictEqual(d.order, 1); + }); + + test('Editor Aware ViewletDescriptor API', function () { + let d = ViewletDescriptor.create(DataExplorerTestViewlet, 'id', 'name', 'class', 5); + assert.strictEqual(d.id, 'id'); + assert.strictEqual(d.name, 'name'); + + d = ViewletDescriptor.create(DataExplorerTestViewlet, 'id', 'name', 'class', 5); + assert.strictEqual(d.id, 'id'); + assert.strictEqual(d.name, 'name'); + }); + + test('Data Explorer Viewlet extension point and registration', function () { + assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).registerViewlet)); + assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlet)); + assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlets)); + + let oldCount = Platform.Registry.as(Extensions.Viewlets).getViewlets().length; + let d = ViewletDescriptor.create(DataExplorerTestViewlet, 'dataExplorer-test-id', 'name'); + Platform.Registry.as(Extensions.Viewlets).registerViewlet(d); + let retrieved = Platform.Registry.as(Extensions.Viewlets).getViewlet('dataExplorer-test-id'); + assert(d === retrieved); + let newCount = Platform.Registry.as(Extensions.Viewlets).getViewlets().length; + assert.equal(oldCount + 1, newCount); + }); +});