mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 17:23:21 -05:00
Add tests for refresh scripting action (#8648)
* Add tests for refresh action * Revert changes to make tree public * Move tests into subsuite
This commit is contained in:
@@ -7,17 +7,18 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ServerTreeView } from 'sql/workbench/contrib/objectExplorer/browser/serverTreeView';
|
||||
import { ConnectionManagementService } from 'sql/workbench/services/connection/browser/connectionManagementService';
|
||||
|
||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
|
||||
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { TestTree } from 'sql/workbench/contrib/objectExplorer/test/browser/treeMock';
|
||||
|
||||
suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
||||
|
||||
let serverTreeView: ServerTreeView;
|
||||
let mockTree: TypeMoq.Mock<Tree>;
|
||||
let mockTree: TypeMoq.Mock<ITree>;
|
||||
let mockRefreshTreeMethod: TypeMoq.Mock<Function>;
|
||||
let capabilitiesService = new TestCapabilitiesService();
|
||||
|
||||
@@ -27,13 +28,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
||||
mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []);
|
||||
mockConnectionManagementService.setup(x => x.hasRegisteredServers()).returns(() => true);
|
||||
serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined, capabilitiesService);
|
||||
let tree = <Tree>{
|
||||
clearSelection() { },
|
||||
getSelection() { },
|
||||
select(selection) { },
|
||||
reveal(reveal) { }
|
||||
};
|
||||
mockTree = TypeMoq.Mock.ofInstance(tree);
|
||||
mockTree = TypeMoq.Mock.ofType(TestTree);
|
||||
(serverTreeView as any)._tree = mockTree.object;
|
||||
mockRefreshTreeMethod = TypeMoq.Mock.ofType(Function);
|
||||
mockRefreshTreeMethod.setup(x => x()).returns(() => Promise.resolve());
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { INavigator } from 'vs/base/common/iterator';
|
||||
import { ITree, IHighlightEvent, ISelectionEvent, IFocusEvent, ITreeStyles } from 'vs/base/parts/tree/browser/tree';
|
||||
import { IItemExpandEvent, IItemCollapseEvent } from 'vs/base/parts/tree/browser/treeModel';
|
||||
|
||||
/**
|
||||
* A basic implementation of ITree to use for testing
|
||||
*/
|
||||
export class TestTree implements ITree {
|
||||
|
||||
readonly onDidChangeFocus: Event<IFocusEvent>;
|
||||
readonly onDidChangeSelection: Event<ISelectionEvent>;
|
||||
readonly onDidChangeHighlight: Event<IHighlightEvent>;
|
||||
readonly onDidExpandItem: Event<IItemExpandEvent>;
|
||||
readonly onDidCollapseItem: Event<IItemCollapseEvent>;
|
||||
readonly onDidDispose: Event<void>;
|
||||
|
||||
constructor() { }
|
||||
|
||||
public style(styles: ITreeStyles): void { }
|
||||
|
||||
get onDidFocus(): Event<void> { return undefined; }
|
||||
|
||||
get onDidBlur(): Event<void> { return undefined; }
|
||||
|
||||
get onDidScroll(): Event<void> { return undefined; }
|
||||
|
||||
public getHTMLElement(): HTMLElement { return undefined; }
|
||||
|
||||
public layout(height?: number, width?: number): void { }
|
||||
|
||||
public domFocus(): void { }
|
||||
|
||||
public isDOMFocused(): boolean { return true; }
|
||||
|
||||
public domBlur(): void { }
|
||||
|
||||
public onVisible(): void { }
|
||||
|
||||
public onHidden(): void { }
|
||||
|
||||
public setInput(element: any): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public getInput(): any { return undefined; }
|
||||
|
||||
public refresh(element: any = null, recursive = true): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public expand(element: any): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public expandAll(elements: any[]): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public collapse(element: any, recursive: boolean = false): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public collapseAll(elements: any[] | null = null, recursive: boolean = false): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public toggleExpansion(element: any, recursive: boolean = false): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public isExpanded(element: any): boolean { return true; }
|
||||
|
||||
public reveal(element: any, relativeTop: number | null = null): Promise<any> { return Promise.resolve(true); }
|
||||
|
||||
public getExpandedElements(): any[] { return []; }
|
||||
|
||||
public getScrollPosition(): number { return 0; }
|
||||
|
||||
public setScrollPosition(pos: number): void { }
|
||||
|
||||
getContentHeight(): number { return 0; }
|
||||
|
||||
public getHighlight(): any { }
|
||||
|
||||
public clearHighlight(eventPayload?: any): void { }
|
||||
|
||||
public setSelection(elements: any[], eventPayload?: any): void { }
|
||||
|
||||
public getSelection(): any[] { return []; }
|
||||
|
||||
public clearSelection(eventPayload?: any): void { }
|
||||
|
||||
public setFocus(element?: any, eventPayload?: any): void { }
|
||||
|
||||
public getFocus(): any { }
|
||||
|
||||
public focusNext(count?: number, eventPayload?: any): void { }
|
||||
|
||||
public focusPrevious(count?: number, eventPayload?: any): void { }
|
||||
|
||||
public focusParent(eventPayload?: any): void { }
|
||||
|
||||
public focusFirstChild(eventPayload?: any): void { }
|
||||
|
||||
public focusFirst(eventPayload?: any, from?: any): void { }
|
||||
|
||||
public focusNth(index: number, eventPayload?: any): void { }
|
||||
|
||||
public focusLast(eventPayload?: any, from?: any): void { }
|
||||
|
||||
public focusNextPage(eventPayload?: any): void { }
|
||||
|
||||
public focusPreviousPage(eventPayload?: any): void { }
|
||||
|
||||
public clearFocus(eventPayload?: any): void { }
|
||||
|
||||
public addTraits(trait: string, elements: any[]): void { }
|
||||
|
||||
public removeTraits(trait: string, elements: any[]): void { }
|
||||
|
||||
public select(element: any, eventPayload?: any): void { }
|
||||
|
||||
public deselect(element: any, eventPayload?: any): void { }
|
||||
|
||||
getNavigator(fromElement?: any, subTreeOnly?: boolean): INavigator<any> { return undefined; }
|
||||
|
||||
public dispose(): void { }
|
||||
}
|
||||
Reference in New Issue
Block a user