Move ::moveItemToPane specs from pane-view-spec to pane-spec

This commit is contained in:
Nathan Sobo
2014-01-14 19:26:47 -07:00
parent 2ee6469b17
commit 2ef74de0f8
2 changed files with 31 additions and 31 deletions

View File

@@ -134,6 +134,29 @@ describe "Pane", ->
expect(pane.getItems()).toEqual [item3, item2, item1, item4]
expect(itemMovedHandler).toHaveBeenCalledWith(item2, 1)
describe "::moveItemToPane(item, pane, index)", ->
[container, pane1, pane2] = []
[item1, item2, item3, item4, item5] = []
beforeEach ->
pane1 = new Pane(items: [new Item("A"), new Item("B"), new Item("C")])
container = new PaneContainer(root: pane1)
pane2 = pane1.splitRight(items: [new Item("D"), new Item("E")])
[item1, item2, item3] = pane1.items
[item4, item5] = pane2.items
it "moves the item to the given pane at the given index", ->
pane1.moveItemToPane(item2, pane2, 1)
expect(pane1.items).toEqual [item1, item3]
expect(pane2.items).toEqual [item4, item2, item5]
describe "when the moved item the last item in the source pane", ->
it "destroys the pane, but not the item", ->
item5.destroy()
pane2.moveItemToPane(item4, pane1, 0)
expect(pane2.isDestroyed()).toBe true
expect(item4.isDestroyed()).toBe false
describe "split methods", ->
[pane1, container] = []

View File

@@ -129,37 +129,14 @@ describe "PaneView", ->
expect(itemMovedHandler).toHaveBeenCalled()
expect(itemMovedHandler.argsForCall[0][1..2]).toEqual [view1, 2]
describe "::moveItemToPane(item, pane, index)", ->
[pane2, view3] = []
beforeEach ->
view3 = new TestView(id: 'view-3', text: "View 3")
pane2 = pane.splitRight(view3)
it "moves the item to the given pane at the given index", ->
pane.moveItemToPane(view1, pane2, 1)
expect(pane.getItems()).toEqual [editor1, view2, editor2]
expect(pane2.getItems()).toEqual [view3, view1]
describe "when it is the last item on the source pane", ->
it "removes the source pane, but does not destroy the item", ->
pane.destroyItem(view1)
pane.destroyItem(view2)
pane.destroyItem(editor2)
expect(pane.getItems()).toEqual [editor1]
pane.moveItemToPane(editor1, pane2, 1)
expect(pane.hasParent()).toBeFalsy()
expect(pane2.getItems()).toEqual [view3, editor1]
expect(editor1.isDestroyed()).toBe false
describe "when the item is a jQuery object", ->
it "preserves data by detaching instead of removing", ->
view1.data('preservative', 1234)
pane.moveItemToPane(view1, pane2, 1)
pane2.activateItemAtIndex(1)
expect(pane2.activeView.data('preservative')).toBe 1234
describe "when an item is moved to another pane", ->
it "detaches the item's view rather than removing it", ->
paneModel2 = paneModel.splitRight()
view1.data('preservative', 1234)
paneModel.moveItemToPane(view1, paneModel2, 1)
expect(view1.data('preservative')).toBe 1234
paneModel2.activateItemAtIndex(1)
expect(view1.data('preservative')).toBe 1234
describe "pane:close", ->
it "destroys all items and removes the pane", ->