 
       it "should clear the focus", ->
         @handler.onMetaClick(@item)
-        expect(Actions.setFocus).toHaveBeenCalledWith({collection: @collection, item: null})
+        expect(@onFocusItem).toHaveBeenCalledWith(null)
 
     it "should expand selection", ->
       @handler.onShiftClick(@item)


    describe "when the select option is passed", ->
      it "should turn the existing focused item into a selected item", ->
        spyOn(FocusedContentStore, 'focused').andCallFake => @itemFocus
        spyOn(FocusedContentStore, 'focusedId').andCallFake -> 'focus'
        @handler.onShift(1, {select: true})
        expect(@dataSource.selection.add).toHaveBeenCalledWith(@itemFocus)

      it "should walk the selection to the shift target", ->
        spyOn(FocusedContentStore, 'focused').andCallFake => @itemFocus
        spyOn(FocusedContentStore, 'focusedId').andCallFake -> 'focus'
        @handler.onShift(1, {select: true})
        expect(@dataSource.selection.walk).toHaveBeenCalledWith({current: @itemFocus, next: @itemAfterFocus})

    describe "when one or more items is selected", ->
      it "should move the keyboard cursor", ->
        @selection = [@itemFocus, @itemAfterFocus, @itemKeyboardFocus]
        spyOn(FocusedContentStore, 'keyboardCursor').andCallFake => @itemKeyboardFocus
        spyOn(FocusedContentStore, 'keyboardCursorId').andCallFake -> 'keyboard-focus'
        @handler.onShift(1, {})
        expect(Actions.setCursorPosition).toHaveBeenCalledWith({collection: @collection, item: @itemAfterKeyboardFocus})

    describe "when no items are selected", ->
      it "should move the focus", ->
        spyOn(FocusedContentStore, 'focused').andCallFake => @itemFocus
        spyOn(FocusedContentStore, 'focusedId').andCallFake -> 'focus'
        @handler.onShift(1, {})
        expect(Actions.setFocus).toHaveBeenCalledWith({collection: @collection, item: @itemAfterFocus})


  describe "_checkSelectionAndFocusConsistency", ->
    describe "when only one item is selected", ->
      beforeEach ->
        spyOn(FocusedContentStore, 'focused').andCallFake -> null
        spyOn(FocusedContentStore, 'focusedId').andCallFake -> null
        @selection = [@item]

      it "should clear the selection and make the item focused", ->
        @handler._checkSelectionAndFocusConsistency()
        expect(@dataSource.selection.clear).toHaveBeenCalled()
        expect(Actions.setFocus).toHaveBeenCalledWith({collection: @collection, item: @item})

        _.findIndex data, (item) -> item.id is id
      count: -> data.length

    @props =
      dataSource: @dataSource
      keyboardCursorId: 'keyboard-focus'
      focused: @itemFocus
      focusedId: 'focus'
      onFocusItem: @onFocusItem
      onSetCursorPosition: @onSetCursorPosition

    @collection = 'threads'
    @isRootSheet = true
    @handler = new MultiselectSplitInteractionHandler(@props)

    spyOn(WorkspaceStore, 'topSheet').andCallFake => {root: @isRootSheet}

  it "should always show focus", ->
    expect(@handler.shouldShowFocus()).toEqual(true)
