cleanup tests (#19732)

This commit is contained in:
Vasu Bhog
2022-06-15 11:08:49 -07:00
committed by GitHub
parent 909c56ffe3
commit 4d320c56f0
4 changed files with 49 additions and 49 deletions

View File

@@ -39,7 +39,7 @@ describe('Add Connection String Execute Step', () => {
// getConnectionString should return a connection string with the password
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve(testConnectionString));
// Include Password Prompt - Yes to include password
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().returns(Promise.resolve(constants.yesString) as any);
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().resolves((constants.yesString) as any);
// setup stub for setting local app setting with connection string
sinon.stub(fs.promises, 'writeFile');
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, sinon.match.any, sinon.match.any).resolves(true);
@@ -50,12 +50,12 @@ describe('Add Connection String Execute Step', () => {
should(quickPickStub.calledOnce).be.true('showQuickPick should have been called');
should(getSettingsFileSpy.calledOnce).be.true('GetSettingsFile method should be called once');
should(addConnectionStringSpy.calledOnce).be.true('addConnectionStringSpy method should be called once');
testExecuteStep.shouldExecute(TypeMoq.It.isAny()).should.be.true();
testExecuteStep.shouldExecute(TypeMoq.It.isAny()).should.be.true('Should execute should be true');
});
it('Should return if no settings file found when creating a new Azure Functions project', async () => {
// stubs and spies for methods in the execute step
let getSettingsFileSpy = sinon.stub(azureFunctionUtils, 'getSettingsFile').withArgs(rootFolderPath).returns(Promise.resolve(undefined));
let getSettingsFileSpy = sinon.stub(azureFunctionUtils, 'getSettingsFile').withArgs(rootFolderPath).resolves((undefined));
let connectionInfo: IConnectionInfo = createTestCredentials();// Mocks promptForConnection
let quickPickStub = sinon.spy(vscode.window, 'showQuickPick');
let addConnectionStringToConfigStub = sinon.spy(azureFunctionUtils, 'addConnectionStringToConfig');
@@ -73,7 +73,7 @@ describe('Add Connection String Execute Step', () => {
// stubs and spies for methods in the execute step
let getSettingsFileSpy = sinon.spy(azureFunctionUtils, 'getSettingsFile').withArgs(rootFolderPath);
let connectionInfo: IConnectionInfo = createTestCredentials();// Mocks promptForConnection
sinon.stub(azureFunctionUtils, 'promptConnectionStringPasswordAndUpdateConnectionString').withArgs(connectionInfo, localSettingsPath).returns(Promise.resolve(undefined));
sinon.stub(azureFunctionUtils, 'promptConnectionStringPasswordAndUpdateConnectionString').withArgs(connectionInfo, localSettingsPath).resolves((undefined));
let addConnectionStringToConfigStub = sinon.spy(azureFunctionUtils, 'addConnectionStringToConfig');
// call execute step on the AzureWizardExecuteStep