2014-01-14 00:56:31 +04:00
|
|
|
PaneContainer = require '../src/pane-container'
|
2014-01-14 00:51:15 +04:00
|
|
|
Pane = require '../src/pane'
|
2014-01-10 03:09:22 +04:00
|
|
|
|
2014-01-14 00:56:31 +04:00
|
|
|
describe "PaneContainer", ->
|
2014-01-10 03:09:22 +04:00
|
|
|
describe "serialization", ->
|
2014-01-10 22:21:46 +04:00
|
|
|
[containerA, pane1A, pane2A, pane3A] = []
|
|
|
|
|
|
|
|
beforeEach ->
|
2014-01-13 04:49:08 +04:00
|
|
|
# This is a dummy item to prevent panes from being empty on deserialization
|
|
|
|
class Item
|
|
|
|
atom.deserializers.add(this)
|
|
|
|
@deserialize: -> new this
|
|
|
|
serialize: -> deserializer: 'Item'
|
|
|
|
|
2014-01-14 00:51:15 +04:00
|
|
|
pane1A = new Pane(items: [new Item])
|
2014-01-14 00:56:31 +04:00
|
|
|
containerA = new PaneContainer(root: pane1A)
|
2014-01-13 04:49:08 +04:00
|
|
|
pane2A = pane1A.splitRight(items: [new Item])
|
|
|
|
pane3A = pane2A.splitDown(items: [new Item])
|
2014-01-10 22:21:46 +04:00
|
|
|
|
|
|
|
it "preserves the focused pane across serialization", ->
|
2014-01-10 03:09:22 +04:00
|
|
|
expect(pane3A.focused).toBe true
|
|
|
|
|
|
|
|
containerB = containerA.testSerialization()
|
2014-01-10 04:40:04 +04:00
|
|
|
[pane1B, pane2B, pane3B] = containerB.getPanes()
|
|
|
|
expect(pane3B.focused).toBe true
|
|
|
|
|
2014-01-10 22:21:46 +04:00
|
|
|
it "preserves the active pane across serialization, independent of focus", ->
|
2014-01-12 07:48:01 +04:00
|
|
|
pane3A.activate()
|
2014-01-10 22:21:46 +04:00
|
|
|
expect(containerA.activePane).toBe pane3A
|
|
|
|
|
|
|
|
containerB = containerA.testSerialization()
|
|
|
|
[pane1B, pane2B, pane3B] = containerB.getPanes()
|
|
|
|
expect(containerB.activePane).toBe pane3B
|
|
|
|
|
2014-01-10 04:40:04 +04:00
|
|
|
describe "::activePane", ->
|
|
|
|
[container, pane1, pane2] = []
|
|
|
|
|
|
|
|
beforeEach ->
|
2014-01-15 22:25:53 +04:00
|
|
|
container = new PaneContainer
|
|
|
|
pane1 = container.root
|
2014-01-10 04:40:04 +04:00
|
|
|
|
2014-01-11 04:25:30 +04:00
|
|
|
it "references the first pane if no pane has been made active", ->
|
2014-01-10 04:40:04 +04:00
|
|
|
expect(container.activePane).toBe pane1
|
|
|
|
expect(pane1.active).toBe true
|
|
|
|
|
2014-01-12 07:48:01 +04:00
|
|
|
it "references the most pane on which ::activate was most recently called", ->
|
2014-01-10 04:40:04 +04:00
|
|
|
pane2 = pane1.splitRight()
|
2014-01-12 07:48:01 +04:00
|
|
|
pane2.activate()
|
2014-01-10 04:40:04 +04:00
|
|
|
expect(container.activePane).toBe pane2
|
|
|
|
expect(pane1.active).toBe false
|
|
|
|
expect(pane2.active).toBe true
|
2014-01-12 07:48:01 +04:00
|
|
|
pane1.activate()
|
2014-01-10 04:40:04 +04:00
|
|
|
expect(container.activePane).toBe pane1
|
|
|
|
expect(pane1.active).toBe true
|
|
|
|
expect(pane2.active).toBe false
|
|
|
|
|
2014-01-11 04:25:30 +04:00
|
|
|
it "is reassigned to the next pane if the current active pane is destroyed", ->
|
2014-01-10 04:40:04 +04:00
|
|
|
pane2 = pane1.splitRight()
|
2014-01-12 07:48:01 +04:00
|
|
|
pane2.activate()
|
2014-01-10 04:40:04 +04:00
|
|
|
pane2.destroy()
|
|
|
|
expect(container.activePane).toBe pane1
|
|
|
|
expect(pane1.active).toBe true
|
2014-01-10 05:17:02 +04:00
|
|
|
|
2014-01-15 22:25:53 +04:00
|
|
|
it "does not allow the root pane to be destroyed", ->
|
|
|
|
pane1.destroy()
|
|
|
|
expect(container.root).toBe pane1
|
|
|
|
expect(pane1.isDestroyed()).toBe false
|