Skip to content

Commit 08aa295

Browse files
committed
spec for reordering with/without addNewTabsAtEnd config
1 parent 8b320a6 commit 08aa295

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

spec/tabs-spec.coffee

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ describe "TabBarView", ->
180180
pane.activateItem(editor2)
181181
expect(tabBar.tabForItem(editor2)).toHaveClass 'modified'
182182

183+
describe "when addNewTabsAtEnd is set to true in package settings", ->
184+
it "adds a tab for the new item at the end of the tab bar", ->
185+
atom.config.set("tabs.addNewTabsAtEnd", true)
186+
item3 = new TestView('Item 3')
187+
pane.activateItem(item3)
188+
expect($(tabBar).find('.tab').length).toBe 4
189+
expect($(tabBar.tabAtIndex(3)).find('.title')).toHaveText 'Item 3'
190+
183191
describe "when addNewTabsAtEnd is set to false in package settings", ->
184192
it "adds a tab for the new item at the same index as the item in the pane", ->
185193
atom.config.set("tabs.addNewTabsAtEnd", false)
@@ -189,14 +197,6 @@ describe "TabBarView", ->
189197
expect($(tabBar).find('.tab').length).toBe 4
190198
expect($(tabBar.tabAtIndex(1)).find('.title')).toHaveText 'Item 3'
191199

192-
describe "when addNewTabsAtEnd is set to true in package settings", ->
193-
it "adds a tab for the new item at the end of the tab bar", ->
194-
atom.config.set("tabs.showIcons", true)
195-
item3 = new TestView('Item 3')
196-
pane.activateItem(item3)
197-
expect($(tabBar).find('.tab').length).toBe 4
198-
expect($(tabBar.tabAtIndex(3)).find('.title')).toHaveText 'Item 3'
199-
200200
describe "when an item is removed from the pane", ->
201201
it "removes the item's tab from the tab bar", ->
202202
pane.destroyItem(item2)
@@ -389,14 +389,28 @@ describe "TabBarView", ->
389389
expect(tab).not.toHaveClass 'modified'
390390

391391
describe "when a pane item moves to a new index", ->
392-
it "updates the order of the tabs to match the new item order", ->
393-
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["Item 1", "sample.js", "Item 2"]
394-
pane.moveItem(item2, 1)
395-
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["Item 1", "Item 2", "sample.js"]
396-
pane.moveItem(editor1, 0)
397-
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["sample.js", "Item 1", "Item 2"]
398-
pane.moveItem(item1, 2)
399-
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["sample.js", "Item 2", "Item 1"]
392+
# behavior is independent of addNewTabs config
393+
describe "when addNewTabsAtEnd is set to true in package settings", ->
394+
it "updates the order of the tabs to match the new item order", ->
395+
atom.config.set("tabs.addNewTabsAtEnd", true)
396+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["Item 1", "sample.js", "Item 2"]
397+
pane.moveItem(item2, 1)
398+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["Item 1", "Item 2", "sample.js"]
399+
pane.moveItem(editor1, 0)
400+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["sample.js", "Item 1", "Item 2"]
401+
pane.moveItem(item1, 2)
402+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["sample.js", "Item 2", "Item 1"]
403+
404+
describe "when addNewTabsAtEnd is set to false in package settings", ->
405+
it "updates the order of the tabs to match the new item order", ->
406+
atom.config.set("tabs.addNewTabsAtEnd", false)
407+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["Item 1", "sample.js", "Item 2"]
408+
pane.moveItem(item2, 1)
409+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["Item 1", "Item 2", "sample.js"]
410+
pane.moveItem(editor1, 0)
411+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["sample.js", "Item 1", "Item 2"]
412+
pane.moveItem(item1, 2)
413+
expect(tabBar.getTabs().map (tab) -> tab.textContent).toEqual ["sample.js", "Item 2", "Item 1"]
400414

401415
describe "context menu commands", ->
402416
beforeEach ->

0 commit comments

Comments
 (0)