diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 9441ef976..8ab7d30e3 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -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] = [] diff --git a/spec/pane-view-spec.coffee b/spec/pane-view-spec.coffee index 86076bb83..2584081c5 100644 --- a/spec/pane-view-spec.coffee +++ b/spec/pane-view-spec.coffee @@ -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] = []