From bc77a79e86d70048277476fdb0fbaca161614b99 Mon Sep 17 00:00:00 2001 From: Vladimir Timofeev Date: Sat, 7 Jan 2017 10:59:22 +0300 Subject: [PATCH] Add test to ensure the state saved when project folders changed. --- spec/main-process/atom-application.test.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index 8af139f21..b9dd62042 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -41,6 +41,39 @@ describe('AtomApplication', function () { electron.app.quit = originalAppQuit }) + describe('project paths', function () { + it('sync application state on changes', async function () { + const dirA = makeTempDir() + const dirB = makeTempDir() + const atomApplication = buildAtomApplication() + + const window = atomApplication.launch(parseCommandLine([])) + await focusWindow(window) + + const addProjectPathFn = function (dir) { + return 'function (sendBackToMainProcess) { atom.project.addPath("' + dir + '"); sendBackToMainProcess(null); }' + } + const removeProjectPathFn = function (dir) { + return 'function (sendBackToMainProcess) { atom.project.removePath("' + dir + '"); sendBackToMainProcess(null); }' + } + + await evalInWebContents(window.browserWindow.webContents, addProjectPathFn(dirA)) + + const appState1 = JSON.parse(fs.readFileSync(path.join(process.env.ATOM_HOME, 'storage', 'application.json'), 'utf8')) + assert.deepEqual(appState1[0].initialPaths, [dirA]) + + await evalInWebContents(window.browserWindow.webContents, addProjectPathFn(dirB)) + + const appState2 = JSON.parse(fs.readFileSync(path.join(process.env.ATOM_HOME, 'storage', 'application.json'), 'utf8')) + assert.deepEqual(appState2[0].initialPaths, [dirA, dirB]) + + await evalInWebContents(window.browserWindow.webContents, removeProjectPathFn(dirA)) + + const appState3 = JSON.parse(fs.readFileSync(path.join(process.env.ATOM_HOME, 'storage', 'application.json'), 'utf8')) + assert.deepEqual(appState3[0].initialPaths, [dirB]) + }) + }) + describe('launch', function () { it('can open to a specific line number of a file', async function () { const filePath = path.join(makeTempDir(), 'new-file')