pulsar/spec/workspace-element-spec.js

896 lines
36 KiB
JavaScript
Raw Normal View History

/** @babel */
2017-03-08 02:56:57 +03:00
/* global getComputedStyle, WheelEvent */
const {ipcRenderer} = require('electron')
const path = require('path')
const temp = require('temp').track()
const {Disposable} = require('event-kit')
const {it, fit, ffit, fffit, beforeEach, afterEach} = require('./async-spec-helpers')
2017-03-08 02:56:57 +03:00
describe('WorkspaceElement', () => {
afterEach(() => { temp.cleanupSync() })
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())
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', () => {
let pane1, pane2, pane3, pane4, pane5, pane6, pane7, pane8, pane9,
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
leftDockPane, rightDockPane, bottomDockPane, workspace, workspaceElement
beforeEach(function () {
atom.config.set('core.destroyEmptyPanes', false)
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()
pane9 = 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', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('above', pane8)
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no rows above the pane', () => {
it('returns null', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('above', pane2)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('above', bottomDockPane)
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', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('below', pane2)
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no rows below the pane', () => {
it('returns null', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('below', pane8)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('below', pane8)
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', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('left', pane6)
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no columns to the left of the pane', () => {
it('returns null', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('left', pane4)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('left', rightDockPane)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('left', pane4)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('left', bottomDockPane)
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', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('right', pane4)
expect(nearestPaneElement).toBe(pane5.getElement())
})
})
describe('when there are no columns to the right of the pane', () => {
it('returns null', () => {
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('right', pane6)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('right', leftDockPane)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('right', pane6)
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()
nearestPaneElement = workspaceElement.nearestVisiblePaneInDirection('right', bottomDockPane)
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)
expect(document.hasFocus()).toBe(true, 'Document needs to be focused to run this test')
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())
})
)
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())
})
)
})
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())
})
)
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())
})
)
})
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())
})
)
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())
})
)
})
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())
})
)
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())
})
)
})
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)
})
)
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)
})
)
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)
workspaceElement.moveActiveItemToPaneAbove({keepOriginal: true})
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneAbove.getActiveItem()).toBe(itemB)
})
)
})
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)
})
)
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)
})
)
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)
workspaceElement.moveActiveItemToPaneBelow({keepOriginal: true})
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneBelow.getActiveItem()).toBe(itemB)
})
)
})
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)
})
)
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)
})
)
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)
workspaceElement.moveActiveItemToPaneOnLeft({keepOriginal: true})
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneOnLeft.getActiveItem()).toBe(itemB)
})
)
})
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)
})
)
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)
})
)
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)
workspaceElement.moveActiveItemToPaneOnRight({keepOriginal: true})
expect(workspace.paneForItem(itemA)).toBe(startingPane)
expect(paneOnRight.getActiveItem()).toBe(itemB)
})
)
})
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'),
getAllowedLocations: () => ['left', 'right'],
}
workspace.getBottomDock().show()
startingPane.activate()
startingPane.activateItem(item)
workspaceElement.moveActiveItemToNearestPaneInDirection('below', {keepOriginal: false})
expect(workspace.paneForItem(item)).toBe(startingPane)
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()
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'),
getDefaultLocation() { return 'left' },
getPreferredWidth() { return 150 }
}),
atom.workspace.open({
element: document.createElement('div'),
getDefaultLocation() { return 'right' },
getPreferredWidth() { return 150 }
}),
atom.workspace.open({
element: document.createElement('div'),
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)
workspaceElement.paneContainer.dispatchEvent(new MouseEvent('mouseleave'))
// --- Right Dock ---
// Mouse over where the toggle button would be if the dock were hovered
moveMouse({clientX: 440, clientY: 150})
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the dock
moveMouse({clientX: 460, clientY: 150})
expectToggleButtonHidden(leftDock)
expectToggleButtonVisible(rightDock, 'icon-chevron-right')
expectToggleButtonHidden(bottomDock)
// Mouse over the toggle button
moveMouse({clientX: 440, clientY: 150})
expectToggleButtonHidden(leftDock)
expectToggleButtonVisible(rightDock, 'icon-chevron-right')
expectToggleButtonHidden(bottomDock)
// Click the toggle button
rightDock.toggleButton.innerElement.click()
expect(rightDock.isVisible()).toBe(false)
expectToggleButtonHidden(rightDock)
// Mouse to edge of the window
moveMouse({clientX: 575, clientY: 150})
expectToggleButtonHidden(rightDock)
moveMouse({clientX: 600, clientY: 150})
expectToggleButtonVisible(rightDock, 'icon-chevron-left')
// Click the toggle button again
rightDock.toggleButton.innerElement.click()
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
moveMouse({clientX: 160, clientY: 150})
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the dock
moveMouse({clientX: 140, clientY: 150})
expectToggleButtonVisible(leftDock, 'icon-chevron-left')
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the toggle button
moveMouse({clientX: 160, clientY: 150})
expectToggleButtonVisible(leftDock, 'icon-chevron-left')
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Click the toggle button
leftDock.toggleButton.innerElement.click()
expect(leftDock.isVisible()).toBe(false)
expectToggleButtonHidden(leftDock)
// Mouse to edge of the window
moveMouse({clientX: 25, clientY: 150})
expectToggleButtonHidden(leftDock)
moveMouse({clientX: 0, clientY: 150})
expectToggleButtonVisible(leftDock, 'icon-chevron-right')
// Click the toggle button again
leftDock.toggleButton.innerElement.click()
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
moveMouse({clientX: 300, clientY: 190})
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonHidden(bottomDock)
// Mouse over the dock
moveMouse({clientX: 300, clientY: 210})
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonVisible(bottomDock, 'icon-chevron-down')
// Mouse over the toggle button
moveMouse({clientX: 300, clientY: 195})
expectToggleButtonHidden(leftDock)
expectToggleButtonHidden(rightDock)
expectToggleButtonVisible(bottomDock, 'icon-chevron-down')
// Click the toggle button
bottomDock.toggleButton.innerElement.click()
expect(bottomDock.isVisible()).toBe(false)
expectToggleButtonHidden(bottomDock)
// Mouse to edge of the window
moveMouse({clientX: 300, clientY: 290})
expectToggleButtonHidden(leftDock)
moveMouse({clientX: 300, clientY: 300})
expectToggleButtonVisible(bottomDock, 'icon-chevron-up')
// Click the toggle button again
bottomDock.toggleButton.innerElement.click()
expect(bottomDock.isVisible()).toBe(true)
expectToggleButtonVisible(bottomDock, 'icon-chevron-down')
})
function moveMouse(coordinates) {
window.dispatchEvent(new MouseEvent('mousemove', coordinates))
advanceClock(100)
}
function expectToggleButtonHidden(dock) {
expect(dock.toggleButton.element).not.toHaveClass('atom-dock-toggle-button-visible')
}
function expectToggleButtonVisible(dock, iconClass) {
expect(dock.toggleButton.element).toHaveClass('atom-dock-toggle-button-visible')
expect(dock.toggleButton.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')
spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake(cb => {
2017-03-08 02:56:57 +03:00
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()
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()
2017-03-08 02:56:57 +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()
2017-03-08 02:56:57 +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
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
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
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
editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', {
2017-03-08 02:56:57 +03:00
wheelDeltaY: 10
}))
expect(atom.config.get('editor.fontSize')).toBe(12)
2017-03-08 02:56:57 +03:00
atom.config.set('editor.zoomFontWhenCtrlScrolling', false)
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)
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
const leftContainer = workspaceElement.querySelector('atom-panel-container.left')
const rightContainer = workspaceElement.querySelector('atom-panel-container.right')
expect(leftContainer.nextSibling).toBe(workspaceElement.verticalAxis)
expect(rightContainer.previousSibling).toBe(workspaceElement.verticalAxis)
const topContainer = workspaceElement.querySelector('atom-panel-container.top')
const bottomContainer = workspaceElement.querySelector('atom-panel-container.bottom')
expect(topContainer.nextSibling).toBe(workspaceElement.paneContainer)
expect(bottomContainer.previousSibling).toBe(workspaceElement.paneContainer)
const headerContainer = workspaceElement.querySelector('atom-panel-container.header')
const footerContainer = workspaceElement.querySelector('atom-panel-container.footer')
expect(headerContainer.nextSibling).toBe(workspaceElement.horizontalAxis)
expect(footerContainer.previousSibling).toBe(workspaceElement.horizontalAxis)
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')
atom.workspace.addHeaderPanel({item: headerItem})
expect(headerItem.offsetWidth).toEqual(workspaceElement.offsetWidth)
const footerItem = document.createElement('div')
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'
const horizontalAxisElement = workspaceElement.querySelector('atom-workspace-axis.horizontal')
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'
atom.workspace.addHeaderPanel({item: headerItem})
expect(headerItem.offsetHeight).toBeGreaterThan(0)
const footerItem = document.createElement('div')
footerItem.style.height = '15px'
atom.workspace.addFooterPanel({item: footerItem})
expect(footerItem.offsetHeight).toBeGreaterThan(0)
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')
expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec'))
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')
expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec'))
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')
expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec'))
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')
expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[1], 'spec'))
ipcRenderer.send.reset()
})
})
2017-03-08 02:56:57 +03:00
})