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

This commit is contained in:
Nathan Sobo
2014-01-14 19:15:11 -07:00
parent 9977884a2c
commit 2ee6469b17
2 changed files with 24 additions and 20 deletions

View File

@@ -114,6 +114,26 @@ describe "Pane", ->
pane.items[1].destroy()
expect(pane.items).toEqual [item1, item3]
describe "::moveItem(item, index)", ->
it "moves the item to the given index and emits an 'item-moved' event with the item and its new index", ->
pane = new Pane(items: [new Item("A"), new Item("B"), new Item("C"), new Item("D")])
[item1, item2, item3, item4] = pane.items
pane.on 'item-moved', itemMovedHandler = jasmine.createSpy("itemMovedHandler")
pane.moveItem(item1, 2)
expect(pane.getItems()).toEqual [item2, item3, item1, item4]
expect(itemMovedHandler).toHaveBeenCalledWith(item1, 2)
itemMovedHandler.reset()
pane.moveItem(item2, 3)
expect(pane.getItems()).toEqual [item3, item1, item4, item2]
expect(itemMovedHandler).toHaveBeenCalledWith(item2, 3)
itemMovedHandler.reset()
pane.moveItem(item2, 1)
expect(pane.getItems()).toEqual [item3, item2, item1, item4]
expect(itemMovedHandler).toHaveBeenCalledWith(item2, 1)
describe "split methods", ->
[pane1, container] = []

View File

@@ -122,28 +122,12 @@ describe "PaneView", ->
pane.destroyItem(editor1)
expect(pane.itemViews.find('.editor').length).toBe 0
describe "::moveItem(item, index)", ->
it "moves the item to the given index and emits a 'pane:item-moved' event with the item and the new index", ->
itemMovedHandler = jasmine.createSpy("itemMovedHandler")
pane.on 'pane:item-moved', itemMovedHandler
pane.moveItem(view1, 2)
expect(pane.getItems()).toEqual [editor1, view2, view1, editor2]
describe "when an item is moved within the same pane", ->
it "emits a 'pane:item-moved' event with the item and the new index", ->
pane.on 'pane:item-moved', itemMovedHandler = jasmine.createSpy("itemMovedHandler")
paneModel.moveItem(view1, 2)
expect(itemMovedHandler).toHaveBeenCalled()
expect(itemMovedHandler.argsForCall[0][1..2]).toEqual [view1, 2]
itemMovedHandler.reset()
pane.moveItem(editor1, 3)
expect(pane.getItems()).toEqual [view2, view1, editor2, editor1]
expect(itemMovedHandler).toHaveBeenCalled()
expect(itemMovedHandler.argsForCall[0][1..2]).toEqual [editor1, 3]
itemMovedHandler.reset()
pane.moveItem(editor1, 1)
expect(pane.getItems()).toEqual [view2, editor1, view1, editor2]
expect(itemMovedHandler).toHaveBeenCalled()
expect(itemMovedHandler.argsForCall[0][1..2]).toEqual [editor1, 1]
itemMovedHandler.reset()
describe "::moveItemToPane(item, pane, index)", ->
[pane2, view3] = []