mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add dialog close validation (#1704)
This commit is contained in:
@@ -307,4 +307,23 @@ suite('ExtHostModelViewDialog Tests', () => {
|
||||
// Then the main thread gets notified of the new details
|
||||
mockProxy.verify(x => x.$setWizardDetails(It.isAny(), It.is(x => x.message === newMessage)), Times.once());
|
||||
});
|
||||
|
||||
test('Main thread can execute dialog close validation', () => {
|
||||
// Set up the main thread mock to record the dialog handle
|
||||
let dialogHandle: number;
|
||||
mockProxy.setup(x => x.$setDialogDetails(It.isAny(), It.isAny())).callback((handle, details) => dialogHandle = handle);
|
||||
|
||||
// Create the dialog and add a validation that records that it has been called
|
||||
let dialog = extHostModelViewDialog.createDialog('dialog_1');
|
||||
extHostModelViewDialog.updateDialogContent(dialog);
|
||||
let callCount = 0;
|
||||
dialog.registerCloseValidator(() => {
|
||||
callCount++;
|
||||
return true;
|
||||
});
|
||||
|
||||
// If I call the validation from the main thread then it should run
|
||||
extHostModelViewDialog.$validateDialogClose(dialogHandle);
|
||||
assert.equal(callCount, 1);
|
||||
});
|
||||
});
|
||||
@@ -60,7 +60,8 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
$onPanelValidityChanged: (handle, valid) => undefined,
|
||||
$onWizardPageChanged: (handle, info) => undefined,
|
||||
$updateWizardPageInfo: (wizardHandle, pageHandles, currentPageIndex) => undefined,
|
||||
$validateNavigation: (handle, info) => undefined
|
||||
$validateNavigation: (handle, info) => undefined,
|
||||
$validateDialogClose: handle => undefined
|
||||
});
|
||||
let extHostContext = <IExtHostContext>{
|
||||
getProxy: proxyType => mockExtHostModelViewDialog.object
|
||||
@@ -347,4 +348,15 @@ suite('MainThreadModelViewDialog Tests', () => {
|
||||
assert.equal(newMessage, wizardDetails.message, 'New message was not included in the fired event');
|
||||
assert.equal(openedWizard.message, wizardDetails.message, 'New message was not set on the wizard');
|
||||
});
|
||||
|
||||
test('Creating a dialog adds a close validation that calls the extension host', () => {
|
||||
mockExtHostModelViewDialog.setup(x => x.$validateDialogClose(It.isAny()));
|
||||
|
||||
// If I call validateClose on the dialog that gets created
|
||||
mainThreadModelViewDialog.$openDialog(dialogHandle);
|
||||
openedDialog.validateClose();
|
||||
|
||||
// Then the call gets forwarded to the extension host
|
||||
mockExtHostModelViewDialog.verify(x => x.$validateDialogClose(It.is(handle => handle === dialogHandle)), Times.once());
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user