fix(xod-client-electron): fix bug with creating workspace without question on IDE launch, fix naming of imported functions in tests

This commit is contained in:
Kirill Shumilov
2017-05-17 12:41:21 +03:00
parent 48ac0f21ab
commit 5be3fbe0be
2 changed files with 16 additions and 11 deletions

View File

@@ -284,10 +284,6 @@ const ensurePath = workspacePath => resolveWorkspacePath(workspacePath)
// :: Path -> Promise Path Error
const spawnWorkspace = workspacePath => spawnWorkspaceFile(workspacePath).then(spawnStdLib);
// :: Path -> Promise Path Error
const ensureWorkspace = workspacePath => validateWorkspace(workspacePath)
.catch(() => spawnWorkspace(workspacePath));
// :: (String -> a -> ()) ->Path -> Promise ProjectMeta[] Error
const spawnAndLoadDefaultProject = (send, workspacePath) => spawnDefaultProject(workspacePath)
.then(enumerateProjects)
@@ -350,12 +346,17 @@ export const onIDELaunch = R.curry(
pathGetter,
oldPath => R.pipeP(
ensurePath,
ensureWorkspace,
pathSaver,
validateWorkspace,
updateWorkspace(send, oldPath)
)(oldPath),
loadProjectsOrSpawnDefault(send)
)().catch(handleError(send))
)()
.catch(catchInvalidWorkspace((err) => {
const force = (err.errorCode === ERROR_CODES.WORKSPACE_DIR_NOT_EMPTY);
pathGetter().then(newPath => requestCreateWorkspace(send, newPath, force));
}))
.catch(handleError(send))
);
// :: (String -> a -> ()) -> (Path -> Promise Path Error) -> Path -> Promise ProjectMeta[] Error

View File

@@ -2,7 +2,7 @@ import chai, { assert, expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { resolve } from 'path';
import fs from 'fs';
import { isFileExist, isDirectoryExist, rmrf } from 'xod-fs';
import { doesFileExist, doesDirectoryExist, rmrf } from 'xod-fs';
import { getProjectName } from 'xod-project';
import {
@@ -101,7 +101,7 @@ describe('Utils', () => {
() => WA.spawnWorkspaceFile(PATH.NOT_EXIST).then((path) => {
const filePath = resolve(path, WORKSPACE_FILENAME);
assert.equal(testFile, filePath);
assert.equal(isFileExist(filePath), true);
assert.equal(doesFileExist(filePath), true);
})
);
});
@@ -110,7 +110,7 @@ describe('Utils', () => {
const destFolder = resolve(PATH.NOT_EXIST, LIBS_FOLDERNAME);
it('Promise.Resolved Path for successfull spawnking',
() => WA.spawnStdLib(PATH.NOT_EXIST).then(() => {
assert.equal(isDirectoryExist(destFolder), true);
assert.equal(doesDirectoryExist(destFolder), true);
fs.readdir(destFolder, (err, files) => {
assert.isAbove(files.length, 0);
assert.includeMembers(files, ['xod']);
@@ -123,7 +123,7 @@ describe('Utils', () => {
const destFolder = resolve(PATH.NOT_EXIST, DEFAULT_PROJECT_NAME);
it('Promise.Resolved Path for successfull spawnking',
() => WA.spawnDefaultProject(PATH.NOT_EXIST).then(() => {
assert.equal(isDirectoryExist(destFolder), true);
assert.equal(doesDirectoryExist(destFolder), true);
fs.readdir(destFolder, (err, files) => {
assert.isAbove(files.length, 0);
assert.includeMembers(files, ['project.xod', 'main']);
@@ -195,7 +195,11 @@ describe('End-to-End', () => {
);
it('not exist workspace: should spawn workspace in homedir, spawn default project and request to open it',
() => WA.onIDELaunch(
sendMockDefault,
(eventName, { path, force }) => {
assert.equal(eventName, EVENTS.REQUEST_CREATE_WORKSPACE);
assert.equal(path, PATH.NOT_EXIST);
assert.isFalse(force);
},
loadMock(PATH.NOT_EXIST),
saveMock(PATH.NOT_EXIST)
)