mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-20 12:00:24 -04:00
Add kube config and kube cluster to arc data controller screens (#13551)
This commit is contained in:
66
extensions/arc/src/test/ui/components/filePicker.test.ts
Normal file
66
extensions/arc/src/test/ui/components/filePicker.test.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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';
|
||||
import * as should from 'should';
|
||||
import * as sinon from 'sinon';
|
||||
import * as vscode from 'vscode';
|
||||
import { Deferred } from '../../../common/promise';
|
||||
import { FilePicker } from '../../../ui/components/filePicker';
|
||||
import { createModelViewMock } from '../../stubs';
|
||||
|
||||
let filePicker: FilePicker;
|
||||
const initialPath = '/path/to/.kube/config';
|
||||
const newFilePath = '/path/to/new/.kube/config';
|
||||
let filePathInputBox: azdata.InputBoxComponent;
|
||||
let browseButton: azdata.ButtonComponent;
|
||||
let flexContainer: azdata.FlexContainer;
|
||||
const browseButtonEmitter = new vscode.EventEmitter<undefined>();
|
||||
describe('filePicker', function (): void {
|
||||
beforeEach(async () => {
|
||||
const { mockModelBuilder, mockInputBoxBuilder, mockButtonBuilder, mockFlexBuilder } = createModelViewMock(browseButtonEmitter);
|
||||
filePicker = new FilePicker(mockModelBuilder.object, initialPath, (_disposable) => { });
|
||||
filePathInputBox = mockInputBoxBuilder.object.component();
|
||||
browseButton = mockButtonBuilder.object.component();
|
||||
flexContainer = mockFlexBuilder.object.component();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
it('browse Button chooses new FilePath', async () => {
|
||||
should(filePathInputBox.value).should.not.be.undefined();
|
||||
filePicker.value!.should.equal(initialPath);
|
||||
flexContainer.items.should.deepEqual([filePathInputBox, browseButton]);
|
||||
const deferred = new Deferred();
|
||||
sinon.stub(vscode.window, 'showOpenDialog').callsFake(async (_options) => {
|
||||
deferred.resolve();
|
||||
return [vscode.Uri.file(newFilePath)];
|
||||
});
|
||||
browseButtonEmitter.fire(undefined); //simulate the click of the browseButton
|
||||
await deferred;
|
||||
filePicker.value!.should.equal(newFilePath);
|
||||
});
|
||||
|
||||
describe('getters and setters', async () => {
|
||||
it('component getter', () => {
|
||||
should(filePicker.component()).equal(flexContainer);
|
||||
});
|
||||
[true, false].forEach(testValue => {
|
||||
it(`Test readOnly with testValue: ${testValue}`, () => {
|
||||
filePicker.readOnly = testValue;
|
||||
filePicker.readOnly!.should.equal(testValue);
|
||||
});
|
||||
it(`Test enabled with testValue: ${testValue}`, () => {
|
||||
filePicker.enabled = testValue;
|
||||
filePicker.enabled!.should.equal(testValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ const radioOptionsInfo = <RadioOptionsInfo>{
|
||||
};
|
||||
const divItems: azdata.Component[] = [];
|
||||
let radioOptionsGroup: RadioOptionsGroup;
|
||||
|
||||
let loadingComponent: azdata.LoadingComponent;
|
||||
|
||||
describe('radioOptionsGroup', function (): void {
|
||||
beforeEach(async () => {
|
||||
const { mockModelView, mockRadioButtonBuilder, mockDivBuilder } = createModelViewMock();
|
||||
const { mockModelBuilder, mockRadioButtonBuilder, mockDivBuilder, mockLoadingBuilder } = createModelViewMock();
|
||||
mockRadioButtonBuilder.reset(); // reset any previous mock so that we can set our own.
|
||||
setupMockComponentBuilder<azdata.RadioButtonComponent, azdata.RadioButtonProperties>(
|
||||
(props) => new FakeRadioButton(props),
|
||||
@@ -41,8 +41,9 @@ describe('radioOptionsGroup', function (): void {
|
||||
},
|
||||
mockDivBuilder
|
||||
);
|
||||
radioOptionsGroup = new RadioOptionsGroup(mockModelView.object, (_disposable) => { });
|
||||
radioOptionsGroup = new RadioOptionsGroup(mockModelBuilder.object, (_disposable) => { });
|
||||
await radioOptionsGroup.load(async () => radioOptionsInfo);
|
||||
loadingComponent = mockLoadingBuilder.object.component();
|
||||
});
|
||||
|
||||
it('verify construction and load', async () => {
|
||||
@@ -72,6 +73,23 @@ describe('radioOptionsGroup', function (): void {
|
||||
should(label.CSSStyles!.color).not.be.undefined();
|
||||
label.CSSStyles!.color.should.equal('Red');
|
||||
});
|
||||
|
||||
describe('getters and setters', async () => {
|
||||
it(`component getter`, () => {
|
||||
radioOptionsGroup.component().should.deepEqual(loadingComponent);
|
||||
});
|
||||
|
||||
[true, false].forEach(testValue => {
|
||||
it(`Test readOnly with testValue: ${testValue}`, () => {
|
||||
radioOptionsGroup.readOnly = testValue;
|
||||
radioOptionsGroup.readOnly!.should.equal(testValue);
|
||||
});
|
||||
it(`Test enabled with testValue: ${testValue}`, () => {
|
||||
radioOptionsGroup.enabled = testValue;
|
||||
radioOptionsGroup.enabled!.should.equal(testValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function verifyRadioGroup() {
|
||||
|
||||
Reference in New Issue
Block a user