diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index cfd1e35d5..f264f1a75 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -146,3 +146,36 @@ describe "Workspace", -> expect(workspace.paneContainer.root.children).toEqual [pane1, pane2] expect(pane2.items).toEqual [editor1] expect(pane1.items).toEqual [] + + describe "::reopenItemSync()", -> + it "opens the uri associated with the last closed pane that isn't currently open", -> + pane = workspace.activePane + workspace.openSync('a') + workspace.openSync('b') + workspace.openSync('file1') + workspace.openSync() + + # does not reopen items with no uri + expect(workspace.activePaneItem.getUri()).toBeUndefined() + pane.destroyActiveItem() + workspace.reopenItemSync() + expect(workspace.activePaneItem.getUri()).not.toBeUndefined() + + # destroy all items + expect(workspace.activePaneItem.getUri()).toBe 'file1' + pane.destroyActiveItem() + expect(workspace.activePaneItem.getUri()).toBe 'b' + pane.destroyActiveItem() + expect(workspace.activePaneItem.getUri()).toBe 'a' + pane.destroyActiveItem() + + # reopens items with uris + expect(workspace.activePaneItem).toBeUndefined() + workspace.reopenItemSync() + expect(workspace.activePaneItem.getUri()).toBe 'a' + + # does not reopen items that are already open + workspace.openSync('b') + expect(workspace.activePaneItem.getUri()).toBe 'b' + workspace.reopenItemSync() + expect(workspace.activePaneItem.getUri()).toBe 'file1' diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index 4e0b078e1..cd6e0c5c7 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -251,39 +251,6 @@ describe "WorkspaceView", -> atom.workspaceView.getActiveView().splitRight() expect(count).toBe 2 - describe ".reopenItemSync()", -> - it "opens the uri associated with the last closed pane that isn't currently open", -> - workspace = atom.workspaceView - pane = workspace.getActivePane() - workspace.openSync('b') - workspace.openSync('file1') - workspace.openSync() - - # does not reopen items with no uri - expect(workspace.getActivePaneItem().getUri()).toBeUndefined() - pane.destroyActiveItem() - workspace.reopenItemSync() - expect(workspace.getActivePaneItem().getUri()).not.toBeUndefined() - - # destroy all items - expect(workspace.getActivePaneItem().getUri()).toBe 'file1' - pane.destroyActiveItem() - expect(workspace.getActivePaneItem().getUri()).toBe 'b' - pane.destroyActiveItem() - expect(workspace.getActivePaneItem().getUri()).toBe 'a' - pane.destroyActiveItem() - - # reopens items with uris - expect(workspace.getActivePaneItem()).toBeUndefined() - workspace.reopenItemSync() - expect(workspace.getActivePaneItem().getUri()).toBe 'a' - - # does not reopen items that are already open - workspace.openSync('b') - expect(workspace.getActivePaneItem().getUri()).toBe 'b' - workspace.reopenItemSync() - expect(workspace.getActivePaneItem().getUri()).toBe 'file1' - describe "core:close", -> it "closes the active pane item until all that remains is a single empty pane", -> atom.config.set('core.destroyEmptyPanes', true)