Files
azuredatastudio/extensions/schema-compare/src/test/schemaCompareDialog.test.ts
Sakshi Sharma 81a1b1a55a Sakshis/scmp test (#13904)
* Fixed a few await issues

* Introduced ModelView as a class member in schemaCompareMainWindow

* Added a few button tests

* Fixed tests

* Add a missing await
2021-01-07 10:15:09 -08:00

70 lines
2.7 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 should from 'should';
import * as vscode from 'vscode';
import * as TypeMoq from 'typemoq';
import * as loc from '../localizedConstants';
import 'mocha';
import { SchemaCompareDialog } from './../dialogs/schemaCompareDialog';
import { SchemaCompareMainWindow } from '../schemaCompareMainWindow';
import { createContext, TestContext } from './testContext';
import { setDacpacEndpointInfo } from './testUtils';
import { SchemaCompareMainWindowTest } from './testSchemaCompareMainWindow';
// Mock test data
const mocksource: string = 'source.dacpac';
const mocktarget: string = 'target.dacpac';
let mockExtensionContext: TypeMoq.IMock<vscode.ExtensionContext>;
let testContext: TestContext;
before(function (): void {
testContext = createContext();
});
describe('SchemaCompareDialog.openDialog @DacFx@', function (): void {
before(() => {
mockExtensionContext = TypeMoq.Mock.ofType<vscode.ExtensionContext>();
mockExtensionContext.setup(x => x.extensionPath).returns(() => '');
});
it('Should be correct when created.', async function (): Promise<void> {
let schemaCompareResult = new SchemaCompareMainWindow(undefined, mockExtensionContext.object);
let dialog = new SchemaCompareDialog(schemaCompareResult);
await dialog.openDialog();
should(dialog.dialog.title).equal(loc.SchemaCompareLabel);
should(dialog.dialog.okButton.label).equal(loc.OkButtonText);
should(dialog.dialog.okButton.enabled).equal(false); // Should be false when open
});
it('Simulate ok button- with both endpoints set to dacpac', async function (): Promise<void> {
let schemaCompareResult = new SchemaCompareMainWindowTest(undefined, mockExtensionContext.object, undefined);
await schemaCompareResult.start(undefined);
schemaCompareResult.sourceEndpointInfo = setDacpacEndpointInfo(mocksource);
schemaCompareResult.targetEndpointInfo = setDacpacEndpointInfo(mocktarget);
let dialog = new SchemaCompareDialog(schemaCompareResult);
await dialog.openDialog();
await dialog.execute();
// Confirm that ok button got clicked
schemaCompareResult.verifyButtonsState({
compareButtonState: true,
optionsButtonState: true,
switchButtonState: true,
openScmpButtonState: true,
saveScmpButtonState: true,
cancelCompareButtonState: false,
selectSourceButtonState: true,
selectTargetButtonState: true,
generateScriptButtonState: false,
applyButtonState: false
});
});
});