fix flaky data workspace test (#13965)

This commit is contained in:
Kim Santiago
2021-01-14 15:45:22 -08:00
committed by GitHub
parent c9fcf4434a
commit 9e3bfea922

View File

@@ -8,7 +8,7 @@ import * as TypeMoq from 'typemoq';
import * as sinon from 'sinon';
import * as vscode from 'vscode';
import * as constants from '../../common/constants';
import { promises as fs } from 'fs';
import * as utils from '../../common/utils';
import { WorkspaceService } from '../../services/workspaceService';
import { OpenExistingDialog } from '../../dialogs/openExistingDialog';
import { createProjectFile, generateUniqueProjectFilePath, generateUniqueWorkspaceFilePath, testProjectType } from '../testUtils';
@@ -47,16 +47,16 @@ suite('Open Existing Dialog', function (): void {
dialog._targetTypeRadioCardGroup?.updateProperty( 'selectedCardId', constants.Workspace);
dialog._filePathTextBox!.value = 'nonExistentWorkspaceFile';
const fileExistStub = sinon.stub(utils, 'fileExist').resolves(false);
const validateResult = await dialog.validate();
const msg = constants.FileNotExistError('workspace', 'nonExistentWorkspaceFile');
should.equal(dialog.dialogObject.message.text, msg);
should.equal(validateResult, false, 'Validation should fail because workspace file does not exist, but passed');
// create a workspace file
// validation should pass if workspace file exists
dialog._filePathTextBox!.value = generateUniqueWorkspaceFilePath();
await fs.writeFile(dialog._filePathTextBox!.value , '');
fileExistStub.resolves(true);
should.equal(await dialog.validate(), true, `Validation should pass because workspace file exists, but failed with: ${dialog.dialogObject.message.text}`);
});