pulsar/spec/workspace-element-spec.js

1069 lines
39 KiB
JavaScript
Raw Normal View History

/** @babel */
2019-02-22 10:55:17 +03:00
const { ipcRenderer } = require('electron')
2018-03-01 02:03:44 +03:00
const etch = require('etch')
2017-03-08 02:56:57 +03:00
const path = require('path')
const temp = require('temp').track()
2019-02-22 10:55:17 +03:00
const { Disposable } = require('event-kit')
2017-03-08 02:56:57 +03:00
2018-03-01 02:03:44 +03:00
const getNextUpdatePromise = () => etch.getScheduler().nextUpdatePromise
describe('WorkspaceElement', () => {
afterEach(() => {
try {
temp.cleanupSync()
} catch (e) {
// Do nothing
}
})
2017-03-08 02:56:57 +03:00
describe('when the workspace element is focused', () => {
it('transfers focus to the active pane', () => {
2017-04-06 01:15:21 +03:00
const workspaceElement = atom.workspace.getElement()
2017-03-08 02:56:57 +03:00
jasmine.attachToDOM(workspaceElement)
const activePaneElement = atom.workspace.getActivePane().getElement()
2017-03-08 02:56:57 +03:00
document.body.focus()
expect(document.activeElement).not.toBe(activePaneElement)
workspaceElement.focus()
expect(document.activeElement).toBe(activePaneElement)
})
})
2017-03-08 02:56:57 +03:00
describe('when the active pane of an inactive pane container is focused', () => {
it('changes the active pane container', () => {
const dock = atom.workspace.getLeftDock()
dock.show()
jasmine.attachToDOM(atom.workspace.getElement())
2019-02-22 10:55:17 +03:00
expect(atom.workspace.getActivePaneContainer()).toBe(
atom.workspace.getCenter()
)
dock
.getActivePane()
.getElement()
.focus()
expect(atom.workspace.getActivePaneContainer()).toBe(dock)
})
})
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('finding the nearest visible pane in a specific direction', () => {
2019-02-22 13:44:30 +03:00
let nearestPaneElement,
pane1,
2019-02-22 10:55:17 +03:00
pane2,
pane3,
pane4,
pane5,
pane6,
pane7,
pane8,
leftDockPane,
rightDockPane,
bottomDockPane,
workspace,
workspaceElement
beforeEach(function () {
atom.config.set('core.destroyEmptyPanes', false)
2019-02-22 10:55:17 +03:00
expect(document.hasFocus()).toBe(
true,
'Document needs to be focused to run this test'
)
workspace = atom.workspace
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
// Set up a workspace center with a grid of 9 panes, in the following
// arrangement, where the numbers correspond to the variable names below.
//
// -------
// |1|2|3|
// -------
// |4|5|6|
// -------
// |7|8|9|
// -------
const container = workspace.getActivePaneContainer()
expect(container.getLocation()).toEqual('center')
expect(container.getPanes().length).toEqual(1)
pane1 = container.getActivePane()
pane4 = pane1.splitDown()
pane7 = pane4.splitDown()
pane2 = pane1.splitRight()
pane3 = pane2.splitRight()
pane5 = pane4.splitRight()
pane6 = pane5.splitRight()
pane8 = pane7.splitRight()
2019-02-22 11:55:30 +03:00
pane8.splitRight()
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const leftDock = workspace.getLeftDock()
const rightDock = workspace.getRightDock()
const bottomDock = workspace.getBottomDock()
expect(leftDock.isVisible()).toBe(false)
expect(rightDock.isVisible()).toBe(false)
expect(bottomDock.isVisible()).toBe(false)
expect(leftDock.getPanes().length).toBe(1)
expect(rightDock.getPanes().length).toBe(1)
expect(bottomDock.getPanes().length).toBe(1)
leftDockPane = leftDock.getPanes()[0]
rightDockPane = rightDock.getPanes()[0]
bottomDockPane = bottomDock.getPanes()[0]
workspaceElement = atom.workspace.getElement()
workspaceElement.style.height = '400px'
workspaceElement.style.width = '400px'
jasmine.attachToDOM(workspaceElement)
})
describe('finding the nearest pane above', () => {
describe('when there are multiple rows above the pane', () => {
it('returns the pane in the adjacent row above', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'above',
pane8
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no rows above the pane', () => {
it('returns null', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'above',
pane2
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBeUndefined() // TODO Expect toBeNull()
})
})
describe('when the bottom dock contains the pane', () => {
it('returns the pane in the adjacent row above', () => {
workspace.getBottomDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'above',
bottomDockPane
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(pane7.getElement())
})
})
})
describe('finding the nearest pane below', () => {
describe('when there are multiple rows below the pane', () => {
it('returns the pane in the adjacent row below', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'below',
pane2
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no rows below the pane', () => {
it('returns null', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'below',
pane8
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBeUndefined() // TODO Expect toBeNull()
})
})
describe('when the bottom dock is visible', () => {
describe("when the workspace center's bottommost row contains the pane", () => {
it("returns the pane in the bottom dock's adjacent row below", () => {
workspace.getBottomDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'below',
pane8
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(bottomDockPane.getElement())
})
})
})
})
describe('finding the nearest pane to the left', () => {
describe('when there are multiple columns to the left of the pane', () => {
it('returns the pane in the adjacent column to the left', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'left',
pane6
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no columns to the left of the pane', () => {
it('returns null', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'left',
pane4
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBeUndefined() // TODO Expect toBeNull()
})
})
describe('when the right dock contains the pane', () => {
it('returns the pane in the adjacent column to the left', () => {
workspace.getRightDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'left',
rightDockPane
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(pane3.getElement())
})
})
describe('when the left dock is visible', () => {
describe("when the workspace center's leftmost column contains the pane", () => {
it("returns the pane in the left dock's adjacent column to the left", () => {
workspace.getLeftDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'left',
pane4
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(leftDockPane.getElement())
})
})
describe('when the bottom dock contains the pane', () => {
it("returns the pane in the left dock's adjacent column to the left", () => {
workspace.getLeftDock().show()
workspace.getBottomDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'left',
bottomDockPane
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(leftDockPane.getElement())
})
})
})
})
describe('finding the nearest pane to the right', () => {
describe('when there are multiple columns to the right of the pane', () => {
it('returns the pane in the adjacent column to the right', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'right',
pane4
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no columns to the right of the pane', () => {
it('returns null', () => {
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'right',
pane6
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBeUndefined() // TODO Expect toBeNull()
})
})
describe('when the left dock contains the pane', () => {
it('returns the pane in the adjacent column to the right', () => {
workspace.getLeftDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'right',
leftDockPane
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(pane1.getElement())
})
})
describe('when the right dock is visible', () => {
describe("when the workspace center's rightmost column contains the pane", () => {
it("returns the pane in the right dock's adjacent column to the right", () => {
workspace.getRightDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'right',
pane6
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(rightDockPane.getElement())
})
})
describe('when the bottom dock contains the pane', () => {
it("returns the pane in the right dock's adjacent column to the right", () => {
workspace.getRightDock().show()
workspace.getBottomDock().show()
2019-02-22 10:55:17 +03:00
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection(
'right',
bottomDockPane
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(nearestPaneElement).toBe(rightDockPane.getElement())
})
})
})
})
})
describe('changing focus, copying, and moving items directionally between panes', function () {
let workspace, workspaceElement, startingPane
beforeEach(function () {
atom.config.set('core.destroyEmptyPanes', false)
2019-02-22 10:55:17 +03:00
expect(document.hasFocus()).toBe(
true,
'Document needs to be focused to run this test'
)
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
workspace = atom.workspace
expect(workspace.getLeftDock().isVisible()).toBe(false)
expect(workspace.getRightDock().isVisible()).toBe(false)
expect(workspace.getBottomDock().isVisible()).toBe(false)
const panes = workspace.getCenter().getPanes()
expect(panes.length).toEqual(1)
startingPane = panes[0]
workspaceElement = atom.workspace.getElement()
workspaceElement.style.height = '400px'
workspaceElement.style.width = '400px'
jasmine.attachToDOM(workspaceElement)
})
describe('::focusPaneViewAbove()', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a row above the focused pane', () =>
it('focuses up to the adjacent row', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneAbove = startingPane.splitUp()
startingPane.activate()
workspaceElement.focusPaneViewAbove()
expect(document.activeElement).toBe(paneAbove.getElement())
2019-02-22 10:55:17 +03:00
}))
describe('when there are no rows above the focused pane', () =>
it('keeps the current pane focused', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
workspaceElement.focusPaneViewAbove()
expect(document.activeElement).toBe(startingPane.getElement())
2019-02-22 10:55:17 +03:00
}))
})
describe('::focusPaneViewBelow()', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a row below the focused pane', () =>
it('focuses down to the adjacent row', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneBelow = startingPane.splitDown()
startingPane.activate()
workspaceElement.focusPaneViewBelow()
expect(document.activeElement).toBe(paneBelow.getElement())
2019-02-22 10:55:17 +03:00
}))
describe('when there are no rows below the focused pane', () =>
it('keeps the current pane focused', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
workspaceElement.focusPaneViewBelow()
expect(document.activeElement).toBe(startingPane.getElement())
2019-02-22 10:55:17 +03:00
}))
})
describe('::focusPaneViewOnLeft()', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a column to the left of the focused pane', () =>
it('focuses left to the adjacent column', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneOnLeft = startingPane.splitLeft()
startingPane.activate()
workspaceElement.focusPaneViewOnLeft()
expect(document.activeElement).toBe(paneOnLeft.getElement())
2019-02-22 10:55:17 +03:00
}))
describe('when there are no columns to the left of the focused pane', () =>
it('keeps the current pane focused', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
workspaceElement.focusPaneViewOnLeft()
expect(document.activeElement).toBe(startingPane.getElement())
2019-02-22 10:55:17 +03:00
}))
})
describe('::focusPaneViewOnRight()', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a column to the right of the focused pane', () =>
it('focuses right to the adjacent column', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneOnRight = startingPane.splitRight()
startingPane.activate()
workspaceElement.focusPaneViewOnRight()
expect(document.activeElement).toBe(paneOnRight.getElement())
2019-02-22 10:55:17 +03:00
}))
describe('when there are no columns to the right of the focused pane', () =>
it('keeps the current pane focused', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
workspaceElement.focusPaneViewOnRight()
expect(document.activeElement).toBe(startingPane.getElement())
2019-02-22 10:55:17 +03:00
}))
})
describe('::moveActiveItemToPaneAbove(keepOriginal)', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a row above the focused pane', () =>
it('moves the active item up to the adjacent row', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneAbove = startingPane.splitUp()
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneAbove()
expect(workspace.paneForItem(item)).toBe(paneAbove)
expect(paneAbove.getActiveItem()).toBe(item)
2019-02-22 10:55:17 +03:00
}))
describe('when there are no rows above the focused pane', () =>
it('keeps the active pane focused', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneAbove()
expect(workspace.paneForItem(item)).toBe(startingPane)
2019-02-22 10:55:17 +03:00
}))
describe('when `keepOriginal: true` is passed in the params', () =>
it('keeps the item and adds a copy of it to the adjacent pane', function () {
const itemA = document.createElement('div')
const itemB = document.createElement('div')
itemA.copy = () => itemB
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneAbove = startingPane.splitUp()
startingPane.activate()
startingPane.activateItem(itemA)
2019-02-22 10:55:17 +03:00
workspaceElement.moveActiveItemToPaneAbove({ keepOriginal: true })
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneAbove.getActiveItem()).toBe(itemB)
2019-02-22 10:55:17 +03:00
}))
})
describe('::moveActiveItemToPaneBelow(keepOriginal)', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a row below the focused pane', () =>
it('moves the active item down to the adjacent row', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneBelow = startingPane.splitDown()
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneBelow()
expect(workspace.paneForItem(item)).toBe(paneBelow)
expect(paneBelow.getActiveItem()).toBe(item)
2019-02-22 10:55:17 +03:00
}))
describe('when there are no rows below the focused pane', () =>
it('keeps the active item in the focused pane', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneBelow()
expect(workspace.paneForItem(item)).toBe(startingPane)
2019-02-22 10:55:17 +03:00
}))
describe('when `keepOriginal: true` is passed in the params', () =>
it('keeps the item and adds a copy of it to the adjacent pane', function () {
const itemA = document.createElement('div')
const itemB = document.createElement('div')
itemA.copy = () => itemB
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneBelow = startingPane.splitDown()
startingPane.activate()
startingPane.activateItem(itemA)
2019-02-22 10:55:17 +03:00
workspaceElement.moveActiveItemToPaneBelow({ keepOriginal: true })
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneBelow.getActiveItem()).toBe(itemB)
2019-02-22 10:55:17 +03:00
}))
})
describe('::moveActiveItemToPaneOnLeft(keepOriginal)', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a column to the left of the focused pane', () =>
it('moves the active item left to the adjacent column', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneOnLeft = startingPane.splitLeft()
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneOnLeft()
expect(workspace.paneForItem(item)).toBe(paneOnLeft)
expect(paneOnLeft.getActiveItem()).toBe(item)
2019-02-22 10:55:17 +03:00
}))
describe('when there are no columns to the left of the focused pane', () =>
it('keeps the active item in the focused pane', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneOnLeft()
expect(workspace.paneForItem(item)).toBe(startingPane)
2019-02-22 10:55:17 +03:00
}))
describe('when `keepOriginal: true` is passed in the params', () =>
it('keeps the item and adds a copy of it to the adjacent pane', function () {
const itemA = document.createElement('div')
const itemB = document.createElement('div')
itemA.copy = () => itemB
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneOnLeft = startingPane.splitLeft()
startingPane.activate()
startingPane.activateItem(itemA)
2019-02-22 10:55:17 +03:00
workspaceElement.moveActiveItemToPaneOnLeft({ keepOriginal: true })
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneOnLeft.getActiveItem()).toBe(itemB)
2019-02-22 10:55:17 +03:00
}))
})
describe('::moveActiveItemToPaneOnRight(keepOriginal)', function () {
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
describe('when there is a column to the right of the focused pane', () =>
it('moves the active item right to the adjacent column', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneOnRight = startingPane.splitRight()
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneOnRight()
expect(workspace.paneForItem(item)).toBe(paneOnRight)
expect(paneOnRight.getActiveItem()).toBe(item)
2019-02-22 10:55:17 +03:00
}))
describe('when there are no columns to the right of the focused pane', () =>
it('keeps the active item in the focused pane', function () {
const item = document.createElement('div')
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToPaneOnRight()
expect(workspace.paneForItem(item)).toBe(startingPane)
2019-02-22 10:55:17 +03:00
}))
describe('when `keepOriginal: true` is passed in the params', () =>
it('keeps the item and adds a copy of it to the adjacent pane', function () {
const itemA = document.createElement('div')
const itemB = document.createElement('div')
itemA.copy = () => itemB
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
const paneOnRight = startingPane.splitRight()
startingPane.activate()
startingPane.activateItem(itemA)
2019-02-22 10:55:17 +03:00
workspaceElement.moveActiveItemToPaneOnRight({ keepOriginal: true })
Add ability to move directionally across *all* visible panes Prior to this change, the following commands successfully move between panes in the workspace center, but they could not move between the the panes in the workspace center and panes in the docks: - window:focus-pane-above - window:focus-pane-below - window:focus-pane-on-left - window:focus-pane-on-right - window:move-active-item-to-pane-above - window:move-active-item-to-pane-below - window:move-active-item-to-pane-on-left - window:move-active-item-to-pane-on-right - window:copy-active-item-to-pane-above - window:copy-active-item-to-pane-below - window:copy-active-item-to-pane-on-left - window:copy-active-item-to-pane-on-right This commit updates these commands to work across all visible panes, regardless of whether the pane is in the workspace center or a dock. Summary of approach: - Add tests for the `nearestVisiblePaneInDirection`, which provides the core logic for the higher-level methods like `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`, etc. - Test the generic logic extensively (i.e., the logic that is independent of whether the given pane resides in the workspace center or a dock) - Also test the navigation between docks and the workspace center - Since the core logic is tested in the new tests above, simplify the tests for the higher-level methods (e.g., `focusPaneViewAbove`, `moveActiveItemToPaneAbove`, `focusPaneViewOnLeft`) to avoid unnecessary duplication. - Add `nearestVisiblePaneInDirection` to `WorkspaceElement`, implemented in terms of the existing `nearestPaneInDirection` method on `PaneContainerElement` for now.
2017-05-22 21:45:59 +03:00
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneOnRight.getActiveItem()).toBe(itemB)
2019-02-22 10:55:17 +03:00
}))
})
describe('::moveActiveItemToNearestPaneInDirection(direction, params)', () => {
describe('when the item is not allowed in nearest pane in the given direction', () => {
it('does not move or copy the active item', function () {
const item = {
element: document.createElement('div'),
2017-06-08 22:44:15 +03:00
getAllowedLocations: () => ['left', 'right']
}
workspace.getBottomDock().show()
startingPane.activate()
startingPane.activateItem(item)
2019-02-22 10:55:17 +03:00
workspaceElement.moveActiveItemToNearestPaneInDirection('below', {
keepOriginal: false
})
expect(workspace.paneForItem(item)).toBe(startingPane)
2019-02-22 10:55:17 +03:00
workspaceElement.moveActiveItemToNearestPaneInDirection('below', {
keepOriginal: true
})
expect(workspace.paneForItem(item)).toBe(startingPane)
})
})
describe("when the item doesn't implement a `copy` function", () => {
it('does not copy the active item', function () {
const item = document.createElement('div')
const paneBelow = startingPane.splitDown()
expect(paneBelow.getItems().length).toEqual(0)
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.focusPaneViewAbove()
2019-02-22 10:55:17 +03:00
workspaceElement.moveActiveItemToNearestPaneInDirection('below', {
keepOriginal: true
})
expect(workspace.paneForItem(item)).toBe(startingPane)
expect(paneBelow.getItems().length).toEqual(0)
})
})
})
})
describe('mousing over docks', () => {
let workspaceElement
beforeEach(() => {
workspaceElement = atom.workspace.getElement()
workspaceElement.style.width = '600px'
workspaceElement.style.height = '300px'
jasmine.attachToDOM(workspaceElement)
})
it('shows the toggle button when the dock is open', async () => {
await Promise.all([
atom.workspace.open({
element: document.createElement('div'),
2019-02-22 10:55:17 +03:00
getDefaultLocation () {
return 'left'
},
getPreferredWidth () {
return 150
}
}),
atom.workspace.open({
element: document.createElement('div'),
2019-02-22 10:55:17 +03:00
getDefaultLocation () {
return 'right'
},
getPreferredWidth () {
return 150
}
}),
atom.workspace.open({
element: document.createElement('div'),
2019-02-22 10:55:17 +03:00
getDefaultLocation () {
return 'bottom'
},
getPreferredHeight () {
return 100
}
})
])
const leftDock = atom.workspace.getLeftDock()
const rightDock = atom.workspace.getRightDock()
const bottomDock = atom.workspace.getBottomDock()
expect(leftDock.isVisible()).toBe(true)
expect(rightDock.isVisible()).toBe(true)
expect(bottomDock.isVisible()).toBe(true)
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// --- Right Dock ---
// Mouse over where the toggle button would be if the dock were hovered
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 440, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the dock
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 460, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
expectToggleButtonVisible(rightDock, 'icon-chevron-right')
expectToggleButtonHidden(bottomDock)
// Mouse over the toggle button
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 440, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
expectToggleButtonVisible(rightDock, 'icon-chevron-right')
expectToggleButtonHidden(bottomDock)
// Click the toggle button
2018-03-01 02:03:44 +03:00
rightDock.refs.toggleButton.refs.innerElement.click()
await getNextUpdatePromise()
expect(rightDock.isVisible()).toBe(false)
expectToggleButtonHidden(rightDock)
// Mouse to edge of the window
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 575, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(rightDock)
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 598, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonVisible(rightDock, 'icon-chevron-left')
// Click the toggle button again
2018-03-01 02:03:44 +03:00
rightDock.refs.toggleButton.refs.innerElement.click()
await getNextUpdatePromise()
expect(rightDock.isVisible()).toBe(true)
expectToggleButtonVisible(rightDock, 'icon-chevron-right')
// --- Left Dock ---
// Mouse over where the toggle button would be if the dock were hovered
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 160, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the dock
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 140, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonVisible(leftDock, 'icon-chevron-left')
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the toggle button
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 160, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonVisible(leftDock, 'icon-chevron-left')
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Click the toggle button
2018-03-01 02:03:44 +03:00
leftDock.refs.toggleButton.refs.innerElement.click()
await getNextUpdatePromise()
expect(leftDock.isVisible()).toBe(false)
expectToggleButtonHidden(leftDock)
// Mouse to edge of the window
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 25, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 2, clientY: 150 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonVisible(leftDock, 'icon-chevron-right')
// Click the toggle button again
2018-03-01 02:03:44 +03:00
leftDock.refs.toggleButton.refs.innerElement.click()
await getNextUpdatePromise()
expect(leftDock.isVisible()).toBe(true)
expectToggleButtonVisible(leftDock, 'icon-chevron-left')
// --- Bottom Dock ---
// Mouse over where the toggle button would be if the dock were hovered
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 300, clientY: 190 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the dock
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 300, clientY: 210 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonVisible(bottomDock, 'icon-chevron-down')
// Mouse over the toggle button
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 300, clientY: 195 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonVisible(bottomDock, 'icon-chevron-down')
// Click the toggle button
2018-03-01 02:03:44 +03:00
bottomDock.refs.toggleButton.refs.innerElement.click()
await getNextUpdatePromise()
expect(bottomDock.isVisible()).toBe(false)
expectToggleButtonHidden(bottomDock)
// Mouse to edge of the window
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 300, clientY: 290 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonHidden(leftDock)
2019-02-22 10:55:17 +03:00
moveMouse({ clientX: 300, clientY: 299 })
2018-03-01 02:03:44 +03:00
await getNextUpdatePromise()
expectToggleButtonVisible(bottomDock, 'icon-chevron-up')
// Click the toggle button again
2018-03-01 02:03:44 +03:00
bottomDock.refs.toggleButton.refs.innerElement.click()
await getNextUpdatePromise()
expect(bottomDock.isVisible()).toBe(true)
expectToggleButtonVisible(bottomDock, 'icon-chevron-down')
})
2018-03-01 02:03:44 +03:00
function moveMouse (coordinates) {
window.dispatchEvent(new MouseEvent('mousemove', coordinates))
advanceClock(100)
}
2019-02-22 10:55:17 +03:00
function expectToggleButtonHidden (dock) {
expect(dock.refs.toggleButton.element).not.toHaveClass(
'atom-dock-toggle-button-visible'
)
}
2019-02-22 10:55:17 +03:00
function expectToggleButtonVisible (dock, iconClass) {
expect(dock.refs.toggleButton.element).toHaveClass(
'atom-dock-toggle-button-visible'
)
2018-03-01 02:03:44 +03:00
expect(dock.refs.toggleButton.refs.iconElement).toHaveClass(iconClass)
}
})
describe('the scrollbar visibility class', () => {
it('has a class based on the style of the scrollbar', () => {
let observeCallback
2017-03-08 02:56:57 +03:00
const scrollbarStyle = require('scrollbar-style')
2019-02-22 10:55:17 +03:00
spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake(
cb => {
observeCallback = cb
return new Disposable(() => {})
}
)
2017-03-08 02:56:57 +03:00
2017-04-06 01:15:21 +03:00
const workspaceElement = atom.workspace.getElement()
2017-03-08 02:56:57 +03:00
observeCallback('legacy')
expect(workspaceElement.className).toMatch('scrollbars-visible-always')
observeCallback('overlay')
expect(workspaceElement).toHaveClass('scrollbars-visible-when-scrolling')
})
})
2017-03-08 02:56:57 +03:00
describe('editor font styling', () => {
let editor, editorElement, workspaceElement
2017-03-08 02:56:57 +03:00
beforeEach(async () => {
await atom.workspace.open('sample.js')
2017-03-08 02:56:57 +03:00
workspaceElement = atom.workspace.getElement()
jasmine.attachToDOM(workspaceElement)
editor = atom.workspace.getActiveTextEditor()
editorElement = editor.getElement()
2017-03-08 02:56:57 +03:00
})
it("updates the font-size based on the 'editor.fontSize' config value", async () => {
2017-03-08 02:56:57 +03:00
const initialCharWidth = editor.getDefaultCharWidth()
2019-02-22 10:55:17 +03:00
expect(getComputedStyle(editorElement).fontSize).toBe(
atom.config.get('editor.fontSize') + 'px'
)
2017-03-08 02:56:57 +03:00
atom.config.set('editor.fontSize', atom.config.get('editor.fontSize') + 5)
await editorElement.component.getNextUpdatePromise()
2019-02-22 10:55:17 +03:00
expect(getComputedStyle(editorElement).fontSize).toBe(
atom.config.get('editor.fontSize') + 'px'
)
expect(editor.getDefaultCharWidth()).toBeGreaterThan(initialCharWidth)
2017-03-08 02:56:57 +03:00
})
it("updates the font-family based on the 'editor.fontFamily' config value", async () => {
2017-03-08 02:56:57 +03:00
const initialCharWidth = editor.getDefaultCharWidth()
let fontFamily = atom.config.get('editor.fontFamily')
expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily)
atom.config.set('editor.fontFamily', 'sans-serif')
fontFamily = atom.config.get('editor.fontFamily')
await editorElement.component.getNextUpdatePromise()
2017-03-08 02:56:57 +03:00
expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily)
expect(editor.getDefaultCharWidth()).not.toBe(initialCharWidth)
2017-03-08 02:56:57 +03:00
})
it("updates the line-height based on the 'editor.lineHeight' config value", async () => {
2017-03-08 02:56:57 +03:00
const initialLineHeight = editor.getLineHeightInPixels()
atom.config.set('editor.lineHeight', '30px')
await editorElement.component.getNextUpdatePromise()
2019-02-22 10:55:17 +03:00
expect(getComputedStyle(editorElement).lineHeight).toBe(
atom.config.get('editor.lineHeight')
)
expect(editor.getLineHeightInPixels()).not.toBe(initialLineHeight)
2017-03-08 02:56:57 +03:00
})
it('increases or decreases the font size when a ctrl-mousewheel event occurs', () => {
2017-03-08 02:56:57 +03:00
atom.config.set('editor.zoomFontWhenCtrlScrolling', true)
atom.config.set('editor.fontSize', 12)
// Zoom out
2019-02-22 10:55:17 +03:00
editorElement.querySelector('span').dispatchEvent(
new WheelEvent('mousewheel', {
wheelDeltaY: -10,
ctrlKey: true
})
)
2017-03-08 02:56:57 +03:00
expect(atom.config.get('editor.fontSize')).toBe(11)
// Zoom in
2019-02-22 10:55:17 +03:00
editorElement.querySelector('span').dispatchEvent(
new WheelEvent('mousewheel', {
wheelDeltaY: 10,
ctrlKey: true
})
)
2017-03-08 02:56:57 +03:00
expect(atom.config.get('editor.fontSize')).toBe(12)
// Not on an atom-text-editor
2019-02-22 10:55:17 +03:00
workspaceElement.dispatchEvent(
new WheelEvent('mousewheel', {
wheelDeltaY: 10,
ctrlKey: true
})
)
2017-03-08 02:56:57 +03:00
expect(atom.config.get('editor.fontSize')).toBe(12)
// No ctrl key
2019-02-22 10:55:17 +03:00
editorElement.querySelector('span').dispatchEvent(
new WheelEvent('mousewheel', {
wheelDeltaY: 10
})
)
2017-03-08 02:56:57 +03:00
expect(atom.config.get('editor.fontSize')).toBe(12)
2017-03-08 02:56:57 +03:00
atom.config.set('editor.zoomFontWhenCtrlScrolling', false)
2019-02-22 10:55:17 +03:00
editorElement.querySelector('span').dispatchEvent(
new WheelEvent('mousewheel', {
wheelDeltaY: 10,
ctrlKey: true
})
)
expect(atom.config.get('editor.fontSize')).toBe(12)
2017-03-08 02:56:57 +03:00
})
})
describe('panel containers', () => {
it('inserts panel container elements in the correct places in the DOM', () => {
2017-04-06 01:15:21 +03:00
const workspaceElement = atom.workspace.getElement()
2017-03-08 02:56:57 +03:00
2019-02-22 10:55:17 +03:00
const leftContainer = workspaceElement.querySelector(
'atom-panel-container.left'
)
const rightContainer = workspaceElement.querySelector(
'atom-panel-container.right'
)
2017-03-08 02:56:57 +03:00
expect(leftContainer.nextSibling).toBe(workspaceElement.verticalAxis)
expect(rightContainer.previousSibling).toBe(workspaceElement.verticalAxis)
2019-02-22 10:55:17 +03:00
const topContainer = workspaceElement.querySelector(
'atom-panel-container.top'
)
const bottomContainer = workspaceElement.querySelector(
'atom-panel-container.bottom'
)
2017-03-08 02:56:57 +03:00
expect(topContainer.nextSibling).toBe(workspaceElement.paneContainer)
2019-02-22 10:55:17 +03:00
expect(bottomContainer.previousSibling).toBe(
workspaceElement.paneContainer
)
2017-03-08 02:56:57 +03:00
2019-02-22 10:55:17 +03:00
const headerContainer = workspaceElement.querySelector(
'atom-panel-container.header'
)
const footerContainer = workspaceElement.querySelector(
'atom-panel-container.footer'
)
2017-03-08 02:56:57 +03:00
expect(headerContainer.nextSibling).toBe(workspaceElement.horizontalAxis)
2019-02-22 10:55:17 +03:00
expect(footerContainer.previousSibling).toBe(
workspaceElement.horizontalAxis
)
2017-03-08 02:56:57 +03:00
2019-02-22 10:55:17 +03:00
const modalContainer = workspaceElement.querySelector(
'atom-panel-container.modal'
)
expect(modalContainer.parentNode).toBe(workspaceElement)
2017-03-08 02:56:57 +03:00
})
it('stretches header/footer panels to the workspace width', () => {
2017-04-06 01:15:21 +03:00
const workspaceElement = atom.workspace.getElement()
2017-03-08 02:56:57 +03:00
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.offsetWidth).toBeGreaterThan(0)
const headerItem = document.createElement('div')
2019-02-22 10:55:17 +03:00
atom.workspace.addHeaderPanel({ item: headerItem })
2017-03-08 02:56:57 +03:00
expect(headerItem.offsetWidth).toEqual(workspaceElement.offsetWidth)
const footerItem = document.createElement('div')
2019-02-22 10:55:17 +03:00
atom.workspace.addFooterPanel({ item: footerItem })
expect(footerItem.offsetWidth).toEqual(workspaceElement.offsetWidth)
2017-03-08 02:56:57 +03:00
})
it('shrinks horizontal axis according to header/footer panels height', () => {
2017-04-06 01:15:21 +03:00
const workspaceElement = atom.workspace.getElement()
2017-03-08 02:56:57 +03:00
workspaceElement.style.height = '100px'
2019-02-22 10:55:17 +03:00
const horizontalAxisElement = workspaceElement.querySelector(
'atom-workspace-axis.horizontal'
)
2017-03-08 02:56:57 +03:00
jasmine.attachToDOM(workspaceElement)
const originalHorizontalAxisHeight = horizontalAxisElement.offsetHeight
expect(workspaceElement.offsetHeight).toBeGreaterThan(0)
expect(originalHorizontalAxisHeight).toBeGreaterThan(0)
const headerItem = document.createElement('div')
headerItem.style.height = '10px'
2019-02-22 10:55:17 +03:00
atom.workspace.addHeaderPanel({ item: headerItem })
2017-03-08 02:56:57 +03:00
expect(headerItem.offsetHeight).toBeGreaterThan(0)
const footerItem = document.createElement('div')
footerItem.style.height = '15px'
2019-02-22 10:55:17 +03:00
atom.workspace.addFooterPanel({ item: footerItem })
2017-03-08 02:56:57 +03:00
expect(footerItem.offsetHeight).toBeGreaterThan(0)
2019-02-22 10:55:17 +03:00
expect(horizontalAxisElement.offsetHeight).toEqual(
originalHorizontalAxisHeight -
headerItem.offsetHeight -
footerItem.offsetHeight
)
2017-03-08 02:56:57 +03:00
})
})
describe("the 'window:toggle-invisibles' command", () => {
it('shows/hides invisibles in all open and future editors', () => {
2017-04-06 01:15:21 +03:00
const workspaceElement = atom.workspace.getElement()
2017-03-08 02:56:57 +03:00
expect(atom.config.get('editor.showInvisibles')).toBe(false)
atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles')
expect(atom.config.get('editor.showInvisibles')).toBe(true)
atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles')
expect(atom.config.get('editor.showInvisibles')).toBe(false)
})
})
describe("the 'window:run-package-specs' command", () => {
it("runs the package specs for the active item's project path, or the first project path", () => {
2017-04-06 01:15:21 +03:00
const workspaceElement = atom.workspace.getElement()
2017-03-08 02:56:57 +03:00
spyOn(ipcRenderer, 'send')
// No project paths. Don't try to run specs.
2017-03-08 02:56:57 +03:00
atom.commands.dispatch(workspaceElement, 'window:run-package-specs')
expect(ipcRenderer.send).not.toHaveBeenCalledWith('run-package-specs')
2017-03-08 02:56:57 +03:00
const projectPaths = [temp.mkdirSync('dir1-'), temp.mkdirSync('dir2-')]
atom.project.setPaths(projectPaths)
// No active item. Use first project directory.
2017-03-08 02:56:57 +03:00
atom.commands.dispatch(workspaceElement, 'window:run-package-specs')
2019-02-22 10:55:17 +03:00
expect(ipcRenderer.send).toHaveBeenCalledWith(
'run-package-specs',
path.join(projectPaths[0], 'spec'),
{}
)
2017-03-08 02:56:57 +03:00
ipcRenderer.send.reset()
// Active item doesn't implement ::getPath(). Use first project directory.
2017-03-08 02:56:57 +03:00
const item = document.createElement('div')
atom.workspace.getActivePane().activateItem(item)
atom.commands.dispatch(workspaceElement, 'window:run-package-specs')
2019-02-22 10:55:17 +03:00
expect(ipcRenderer.send).toHaveBeenCalledWith(
'run-package-specs',
path.join(projectPaths[0], 'spec'),
{}
)
2017-03-08 02:56:57 +03:00
ipcRenderer.send.reset()
// Active item has no path. Use first project directory.
2017-03-08 02:56:57 +03:00
item.getPath = () => null
atom.commands.dispatch(workspaceElement, 'window:run-package-specs')
2019-02-22 10:55:17 +03:00
expect(ipcRenderer.send).toHaveBeenCalledWith(
'run-package-specs',
path.join(projectPaths[0], 'spec'),
{}
)
2017-03-08 02:56:57 +03:00
ipcRenderer.send.reset()
// Active item has path. Use project path for item path.
2017-03-08 02:56:57 +03:00
item.getPath = () => path.join(projectPaths[1], 'a-file.txt')
atom.commands.dispatch(workspaceElement, 'window:run-package-specs')
2019-02-22 10:55:17 +03:00
expect(ipcRenderer.send).toHaveBeenCalledWith(
'run-package-specs',
path.join(projectPaths[1], 'spec'),
{}
)
ipcRenderer.send.reset()
})
2019-02-22 10:55:17 +03:00
it('passes additional options to the spec window', () => {
const workspaceElement = atom.workspace.getElement()
spyOn(ipcRenderer, 'send')
const projectPath = temp.mkdirSync('dir1-')
atom.project.setPaths([projectPath])
2019-02-22 10:55:17 +03:00
workspaceElement.runPackageSpecs({
env: { ATOM_GITHUB_BABEL_ENV: 'coverage' }
})
expect(ipcRenderer.send).toHaveBeenCalledWith(
2019-02-22 10:55:17 +03:00
'run-package-specs',
path.join(projectPath, 'spec'),
{ env: { ATOM_GITHUB_BABEL_ENV: 'coverage' } }
)
})
})
2017-03-08 02:56:57 +03:00
})