本文整理匯總了TypeScript中sql/parts/query/editor/queryEditor.QueryEditor類的典型用法代碼示例。如果您正苦於以下問題:TypeScript QueryEditor類的具體用法?TypeScript QueryEditor怎麽用?TypeScript QueryEditor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QueryEditor類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('createEditor creates only the taskbar', (done) => {
// If I call createEditor
let editor: QueryEditor = getQueryEditor();
editor.createEditor(parentBuilder.getHTMLElement());
// The taskbar should be created
assert.equal(!!editor.taskbar, true);
assert.equal(!!editor.taskbarContainer, true);
// But Nothing else should be created
assert.equal(!!editor.getContainer(), false);
assert.equal(!!editor.sqlEditor, false);
assert.equal(!!editor.sqlEditorContainer, false);
assert.equal(!!editor.resultsEditor, false);
assert.equal(!!editor.resultsEditorContainer, false);
assert.equal(!!editor.sash, false);
assert.equal(!!editor._isResultsEditorVisible(), false);
done();
});
示例2: suite
suite('SQL QueryEditor Tests', () => {
let queryModelService: QueryModelService;
let instantiationService: TypeMoq.Mock<InstantiationService>;
let themeService: TestThemeService = new TestThemeService();
let notificationService: TypeMoq.Mock<INotificationService>;
let editorDescriptorService: TypeMoq.Mock<EditorDescriptorService>;
let connectionManagementService: TypeMoq.Mock<ConnectionManagementService>;
let configurationService: TypeMoq.Mock<ConfigurationService>;
let memento: TypeMoq.Mock<Memento>;
let queryInput: QueryInput;
let queryInput2: QueryInput;
let parentBuilder: Builder;
let mockEditor: any;
let getQueryEditor = function (): QueryEditor {
return new QueryEditor(
undefined,
themeService,
instantiationService.object,
undefined,
undefined,
undefined,
editorDescriptorService.object,
undefined,
undefined,
configurationService.object);
};
setup(() => {
// Setup DOM elements
let element = DOM.$('queryEditorParent');
parentBuilder = new Builder(element);
// Create object to mock the Editor classes
// QueryResultsEditor fails at runtime due to the way we are importing Angualar,
// so a {} mock is used here. This mock simply needs to have empty method stubs
// for all called runtime methods
mockEditor = {
_bootstrapAngular: function () { },
setInput: function () { },
createEditor: function () { },
create: function () { },
setVisible: function () { },
layout: function () { },
dispose: function () { }
};
// Mock InstantiationService to give us our mockEditor
instantiationService = TypeMoq.Mock.ofType(InstantiationService, TypeMoq.MockBehavior.Loose);
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny())).returns((input) => {
return new TPromise((resolve) => resolve(mockEditor));
});
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((input) => {
return new TPromise((resolve) => resolve(new RunQueryAction(undefined, undefined, undefined)));
});
// Setup hook to capture calls to create the listDatabase action
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
if (classDef.ID) {
if (classDef.ID === 'listDatabaseQueryActionItem') {
return new ListDatabasesActionItem(editor, action, connectionManagementService.object, undefined, undefined, undefined, configurationService.object);
}
}
// Default
return new RunQueryAction(undefined, undefined, undefined);
});
// Mock EditorDescriptorService to give us a mock editor description
let descriptor: IEditorDescriptor = {
getId: function (): string { return 'id'; },
getName: function (): string { return 'name'; },
describes: function (obj: any): boolean { return true; },
instantiate(instantiationService: IInstantiationService): BaseEditor { return undefined; }
};
editorDescriptorService = TypeMoq.Mock.ofType(EditorDescriptorService, TypeMoq.MockBehavior.Loose);
editorDescriptorService.setup(x => x.getEditor(TypeMoq.It.isAny())).returns(() => descriptor);
configurationService = TypeMoq.Mock.ofInstance({
getValue: () => undefined,
onDidChangeConfiguration: () => undefined
} as any);
configurationService.setup(x => x.getValue(TypeMoq.It.isAny())).returns(() => {
return { enablePreviewFeatures: true };
});
// Create a QueryInput
let filePath = 'someFile.sql';
let uri: URI = URI.parse(filePath);
let fileInput = new UntitledEditorInput(uri, false, '', '', '', instantiationService.object, undefined, undefined, undefined);
let queryResultsInput: QueryResultsInput = new QueryResultsInput(uri.fsPath, configurationService.object);
queryInput = new QueryInput('first', fileInput, queryResultsInput, undefined, undefined, undefined, undefined, undefined);
// Create a QueryInput to compare to the previous one
let filePath2 = 'someFile2.sql';
let uri2: URI = URI.parse(filePath2);
let fileInput2 = new UntitledEditorInput(uri2, false, '', '', '', instantiationService.object, undefined, undefined, undefined);
let queryResultsInput2: QueryResultsInput = new QueryResultsInput(uri2.fsPath, configurationService.object);
queryInput2 = new QueryInput('second', fileInput2, queryResultsInput2, undefined, undefined, undefined, undefined, undefined);
// Mock IMessageService
//.........這裏部分代碼省略.........