mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
ML extension - Improving predict parameter mapping experience (#10264)
This commit is contained in:
@@ -9,11 +9,13 @@ import * as TypeMoq from 'typemoq';
|
||||
import { ApiWrapper } from '../../common/apiWrapper';
|
||||
import { createViewContext } from './utils';
|
||||
import { DashboardWidget } from '../../views/widgets/dashboardWidget';
|
||||
import { PredictService } from '../../prediction/predictService';
|
||||
|
||||
interface TestContext {
|
||||
apiWrapper: TypeMoq.IMock<ApiWrapper>;
|
||||
view: azdata.ModelView;
|
||||
onClick: vscode.EventEmitter<any>;
|
||||
predictService: TypeMoq.IMock<PredictService>;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,15 +26,22 @@ function createContext(): TestContext {
|
||||
return {
|
||||
apiWrapper: viewTestContext.apiWrapper,
|
||||
view: viewTestContext.view,
|
||||
onClick: viewTestContext.onClick
|
||||
onClick: viewTestContext.onClick,
|
||||
predictService: TypeMoq.Mock.ofType(PredictService)
|
||||
};
|
||||
}
|
||||
|
||||
describe('Dashboard widget', () => {
|
||||
it('Should create view components successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
const dashboard = new DashboardWidget(testContext.apiWrapper.object, '');
|
||||
dashboard.register();
|
||||
|
||||
testContext.apiWrapper.setup(x => x.registerWidget(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(async ( handler) => {
|
||||
await handler(testContext.view);
|
||||
});
|
||||
|
||||
testContext.predictService.setup(x => x.serverSupportOnnxModel()).returns(() => Promise.resolve(true));
|
||||
const dashboard = new DashboardWidget(testContext.apiWrapper.object, '', testContext.predictService.object);
|
||||
await dashboard.register();
|
||||
testContext.onClick.fire(undefined);
|
||||
testContext.apiWrapper.verify(x => x.executeCommand(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user