         editor.setCursorBufferPosition([0, Infinity])
         wrapperView.show()
         expect(node.querySelector('.cursor').style['-webkit-transform']).toBe "translate3d(#{9 * charWidth}px, 0px, 0px)"
+
+  buildMouseEvent = (type, properties...) ->
+    properties = extend({bubbles: true, cancelable: true}, properties...)
+    event = new MouseEvent(type, properties)
+    Object.defineProperty(event, 'which', get: -> properties.which) if properties.which?
+    if properties.target?
+      Object.defineProperty(event, 'target', get: -> properties.target)
+      Object.defineProperty(event, 'srcObject', get: -> properties.target)
+    event

      clientX = scrollViewClientRect.left + positionOffset.left - editor.getScrollLeft()
      clientY = scrollViewClientRect.top + positionOffset.top - editor.getScrollTop()
      {clientX, clientY}

    buildMouseEvent = (type, properties...) ->
      properties = extend({bubbles: true, cancelable: true}, properties...)
      event = new MouseEvent(type, properties)
      Object.defineProperty(event, 'which', get: -> properties.which) if properties.which?
      event

  describe "focus handling", ->
    inputNode = null

        [gutterNode] = []

        buildClickEvent = (target) ->
          buildMouseEvent('click', {target})

        beforeEach ->
          gutterNode = node.querySelector('.gutter')

        it "folds and unfolds the block represented by the fold indicator when clicked", ->
          expect(lineNumberHasClass(1, 'folded')).toBe false

          lineNumber = component.lineNumberNodeForScreenRow(1)
          target = lineNumber.querySelector('.icon-right')

          target.dispatchEvent(buildClickEvent(target))
          expect(lineNumberHasClass(1, 'folded')).toBe true

          lineNumber = component.lineNumberNodeForScreenRow(1)
          target = lineNumber.querySelector('.icon-right')

          target.dispatchEvent(buildClickEvent(target))
          expect(lineNumberHasClass(1, 'folded')).toBe false

        it "does not fold when the line number node is clicked", ->
          component.onClickGutter(buildClickEvent(component.lineNumberNodeForScreenRow(1)))
          expect(lineNumberHasClass(1, 'folded')).toBe false

    describe "when decorations are used", ->
      describe "when decorations are applied to buffer rows", ->
