From 548018e9b29ea7fb93ae68efb340cf66b35c5bb0 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 27 Aug 2014 10:12:34 -0600 Subject: [PATCH] Add spec for onDidRemoveItem observers when moving items to other panes --- spec/pane-spec.coffee | 7 +++++++ src/pane.coffee | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 71c9fcc03..ab9ba7661 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -366,6 +366,13 @@ describe "Pane", -> expect(pane1.getItems()).toEqual [item1, item3] expect(pane2.getItems()).toEqual [item4, item2, item5] + it "invokes ::onDidRemoveItem() observers", -> + events = [] + pane1.onDidRemoveItem (event) -> events.push(event) + pane1.moveItemToPane(item2, pane2, 1) + + expect(events).toEqual [{item: item2, index: 1, destroyed: false}] + describe "when the moved item the last item in the source pane", -> beforeEach -> item5.destroy() diff --git a/src/pane.coffee b/src/pane.coffee index 23f188d25..fc8fee05e 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -211,7 +211,7 @@ class Pane extends Model @addItem(item, index + i) for item, i in items items - removeItem: (item, destroyed) -> + removeItem: (item, destroyed=false) -> index = @items.indexOf(item) return if index is -1 if item is @activeItem