Files
azuredatastudio/extensions/query-store/src/test/testUtils.ts
Benjin Dubishar d9b5d71148 Adding Chart component (#24357)
* added doughnut chart component

* Changing chart to doughnutChart

* reverting to genreic chart component

* adding more chart supoort

* fix minor errors

* resolve some PR comments

* native chartjs, keyboard navigation and chart options

* fix build errors

* fix chart.js/auto error

* resolve PR comments

* modify chartdataset API

* Refactoring (#24327)

* working - displaying chart data with convert

* working - introduced typed properties

* working, added BarChartConfiguration to type param

* removed ChartProperties type param

* Adding doughnut support

* Correcting number vs. point issue

* including the right changes this time

* commenting out no-longer-used labels prop

* remove hardcoded canvasID, enabled Scatterplot config

* Moved graph testing to sample extension

* Reorganizing types; adding test back to assessment dialog

* Adding example for bubble chart

* Polar area working

* cleanup

* adding draw when options isn't set

* Moving chart example configs to other file

* some cleanup

* added some docstrings

* add multiple datasets to test scatter plot

* update scatter plot example in sample

* Adding height/width support

* swapping to `as` cast

* title working

* Settling chart title and legend display

* Adding comments

* updating data working

* Updating samples

* Typo in comment

* Reverting changes made for development

* Elaborating on color in docstrings

* Separating Data and Options in component payloads

* Removing chartId as an exposed property

* Changing chartType property to TChartType

* Fleshing out types file comments

* fixing scoping of chart component properties; renaming chart canvas ID prop

* correct internal chart options typing

* removing commented-out code

* removing unused ChartClickEvent type until data selection eventing is implemented

* renaming function

* deleted commented-out code

* Adding options setters that went missing after splitting Config to Data + Options

* adding type predicates for data conversion

* Adding back type setting (dropped when chart type conversion moved)

* Narrowing type for 'type'

* Fixing typos in docstring

---------

Co-authored-by: Deepak Saini <deepaksaini@microsoft.com>
Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
Co-authored-by: Aasim Khan <aaskhan@microsoft.com>
Co-authored-by: Deepak Saini <deepak.saini1996@gmail.com>
2023-09-13 20:11:09 -07:00

117 lines
3.2 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
export interface TestContext {
view: azdata.ModelView;
component: azdata.Component
}
export function createViewContext(): TestContext {
let componentBase: azdata.Component = {
id: '',
updateProperties: () => Promise.resolve(),
updateProperty: () => Promise.resolve(),
updateCssStyles: undefined!,
onValidityChanged: undefined!,
valid: true,
validate: undefined!,
focus: undefined!,
dispose() { }
};
const components: azdata.Component[] = [];
let container = {
clearItems: () => { },
addItems: () => { },
addItem: () => { },
removeItem: () => true,
insertItem: () => { },
items: components,
setLayout: () => { },
setItemLayout: () => { },
updateCssStyles: () => { }
};
let flex: azdata.FlexContainer = Object.assign({}, componentBase, container, {
});
let flexBuilder: azdata.FlexBuilder = Object.assign({}, {
component: () => flex,
withProperties: () => flexBuilder,
withValidation: () => flexBuilder,
withItems: () => flexBuilder,
withLayout: () => flexBuilder,
withProps: () => flexBuilder
});
let split: azdata.SplitViewContainer = Object.assign({}, componentBase, container, {
});
let splitViewBuilder: azdata.SplitViewBuilder = Object.assign({}, {
component: () => split,
withProperties: () => splitViewBuilder,
withValidation: () => splitViewBuilder,
withItems: () => splitViewBuilder,
withLayout: () => splitViewBuilder,
withProps: () => splitViewBuilder
});
let view: azdata.ModelView = {
onClosed: undefined!,
connection: undefined!,
serverInfo: undefined!,
valid: true,
onValidityChanged: undefined!,
validate: undefined!,
initializeModel: () => { return Promise.resolve(); },
dispose() { },
modelBuilder: {
listView: undefined!,
radioCardGroup: undefined!,
chart: undefined!,
navContainer: undefined!,
divContainer: undefined!,
flexContainer: () => flexBuilder,
splitViewContainer: () => splitViewBuilder,
card: undefined!,
inputBox: () => undefined!,
checkBox: undefined!,
radioButton: () => undefined!,
webView: undefined!,
editor: undefined!,
diffeditor: undefined!,
text: () => undefined!,
image: () => undefined!,
button: () => undefined!,
dropDown: () => undefined!,
tree: undefined!,
listBox: undefined!,
table: undefined!,
declarativeTable: () => undefined!,
dashboardWidget: undefined!,
dashboardWebview: undefined!,
formContainer: () => undefined!,
groupContainer: undefined!,
toolbarContainer: undefined!,
loadingComponent: () => undefined!,
fileBrowserTree: undefined!,
hyperlink: undefined!,
tabbedPanel: undefined!,
separator: undefined!,
propertiesContainer: undefined!,
infoBox: undefined!,
slider: undefined!,
executionPlan: undefined!,
}
};
return {
view: view,
component: componentBase
};
}