Add tests for pending pane items

This commit is contained in:
Katrina Uychaco
2016-01-05 10:38:13 -08:00
parent def62fc6c7
commit 67d49955f1

View File

@@ -18,6 +18,8 @@ describe "Pane", ->
onDidDestroy: (fn) -> @emitter.on('did-destroy', fn)
destroy: -> @destroyed = true; @emitter.emit('did-destroy')
isDestroyed: -> @destroyed
isPending: -> @pending
pending: false
beforeEach ->
confirm = spyOn(atom.applicationDelegate, 'confirm')
@@ -153,6 +155,26 @@ describe "Pane", ->
pane.activateItem(pane.itemAtIndex(1))
expect(observed).toEqual [pane.itemAtIndex(1)]
it "replaces pending items", ->
itemC = new Item("C")
itemD = new Item("D")
itemC.pending = true
itemD.pending = true
expect(itemC.isPending()).toBe true
pane.activateItem(itemC)
expect(pane.getItems().length).toBe 3
expect(pane.getActiveItem()).toBe pane.itemAtIndex(1)
expect(itemD.isPending()).toBe true
pane.activateItem(itemD)
expect(pane.getItems().length).toBe 3
expect(pane.getActiveItem()).toBe pane.itemAtIndex(1)
pane.activateItem(pane.itemAtIndex(2))
expect(pane.getItems().length).toBe 2
expect(pane.getActiveItem()).toBe pane.itemAtIndex(1)
describe "::activateNextItem() and ::activatePreviousItem()", ->
it "sets the active item to the next/previous item, looping around at either end", ->
pane = new Pane(paneParams(items: [new Item("A"), new Item("B"), new Item("C")]))