diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index c0cbd8d54..343981016 100644 --- a/spec/integration/startup-spec.coffee +++ b/spec/integration/startup-spec.coffee @@ -24,22 +24,6 @@ describe "Starting Atom", -> tempDirPath = temp.mkdirSync("empty-dir") otherTempDirPath = temp.mkdirSync("another-temp-dir") - describe "opening a new file", -> - it "opens the parent directory and creates an empty text editor", -> - runAtom [path.join(tempDirPath, "new-file")], {ATOM_HOME: atomHome}, (client) -> - client - .treeViewRootDirectories() - .then ({value}) -> expect(value).toEqual([tempDirPath]) - - .waitForExist("atom-text-editor", 5000) - .then (exists) -> expect(exists).toBe true - .waitForPaneItemCount(1, 1000) - .click("atom-text-editor") - .keys("Hello!") - .execute -> atom.workspace.getActiveTextEditor().getText() - .then ({value}) -> expect(value).toBe "Hello!" - .dispatchCommand("editor:delete-line") - describe "launching with no path", -> it "reopens any previously opened windows", -> runAtom [tempDirPath], {ATOM_HOME: atomHome}, (client) -> diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index b634229a1..58c4b8103 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -277,6 +277,21 @@ describe('AtomApplication', function () { }) assert.equal(itemCount, 0) }) + + it('opens an empty text editor and loads its parent directory in the tree-view when launched with a new file path', async function () { + const atomApplication = buildAtomApplication() + const newFilePath = path.join(makeTempDir(), 'new-file') + const window = atomApplication.openWithOptions(parseCommandLine([newFilePath])) + await window.loadedPromise + const {editorTitle, editorText} = await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) { + atom.workspace.onDidChangeActivePaneItem(function (editor) { + sendBackToMainProcess({editorTitle: editor.getTitle(), editorText: editor.getText()}) + }) + }) + assert.equal(editorTitle, path.basename(newFilePath)) + assert.equal(editorText, '') + assert.deepEqual(await getTreeViewRootDirectories(window), [path.dirname(newFilePath)]) + }) }) function buildAtomApplication () { @@ -287,6 +302,7 @@ describe('AtomApplication', function () { atomApplicationsToDestroy.push(atomApplication) return atomApplication } + function makeTempDir (name) { return fs.realpathSync(temp.mkdirSync(name)) }