         expect(range.end).toEqual({row: 5, column: 27})
         expect(editor.getCursorScreenPosition()).toEqual(row: 5, column: 27)
 
+    describe "trip-click and drag", ->
       it "creates a selection from the line underneath an initial triple click to mouse's new location ", ->
         editor.attachToDom()
         editor.css(position: 'absolute', top: 10, left: 10)

        expect(range.end).toEqual({row: 5, column: 27})
        expect(editor.getCursorScreenPosition()).toEqual(row: 5, column: 27)

      it "creates a selection from the word underneath an initial double click to mouse's new location ", ->
        editor.attachToDom()
        editor.css(position: 'absolute', top: 10, left: 10)

        editor.setFontSize(10)
        expect(editor.renderedLines.find(".line").length).toBeGreaterThan originalLineCount

  describe "mouse events", ->
    beforeEach ->
      editor.attachToDom()
      editor.css(position: 'absolute', top: 10, left: 10)

    describe "single-click", ->
      it "re-positions the cursor to the clicked row / column", ->
        expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0)

        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [3, 10])
        expect(editor.getCursorScreenPosition()).toEqual(row: 3, column: 10)

      describe "when the lines are scrolled to the right", ->
        it "re-positions the cursor on the clicked location", ->
          setEditorWidthInChars(editor, 30)
          expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0)
          editor.renderedLines.trigger mousedownEvent(editor: editor, point: [3, 30]) # scrolls lines to the right
          editor.renderedLines.trigger mousedownEvent(editor: editor, point: [3, 50])
          expect(editor.getCursorBufferPosition()).toEqual(row: 3, column: 50)

    describe "double-click", ->
      it "selects the word under the cursor", ->
        expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0)
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [0, 8], originalEvent: {detail: 1})
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [0, 8], originalEvent: {detail: 2})
        editor.renderedLines.trigger 'mouseup'
        expect(editor.getSelectedText()).toBe "quicksort"

    describe "triple/quardruple/etc-click", ->
      it "selects the line under the cursor", ->
        expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0)

        # Triple click
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [1, 8], originalEvent: {detail: 1})
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [1, 8], originalEvent: {detail: 2})
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [1, 8], originalEvent: {detail: 3})
        editor.renderedLines.trigger 'mouseup'
        expect(editor.getSelectedText()).toBe "  var sort = function(items) {"

        # Quad click
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [2, 3], originalEvent: {detail: 1})
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [2, 3], originalEvent: {detail: 2})
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [2, 3], originalEvent: {detail: 3})
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [2, 3], originalEvent: {detail: 4})
        editor.renderedLines.trigger 'mouseup'
        expect(editor.getSelectedText()).toBe "    if (items.length <= 1) return items;"

    describe "shift-click", ->
      it "selects from the cursor's current location to the clicked location", ->
        editor.setCursorScreenPosition([4, 7])
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true)
        expect(editor.getSelection().getScreenRange()).toEqual [[4, 7], [5, 24]]

    describe "shift-double-click", ->
      it "expands the selection to include the double-clicked word", ->
        editor.setCursorScreenPosition([4, 7])
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 1 })
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 2 })
        editor.renderedLines.trigger 'mouseup'
        expect(editor.getSelection().getScreenRange()).toEqual [[4, 7], [5, 27]]

    describe "shift-triple-click", ->
      it "expands the selection to include the triple-clicked line", ->
        editor.setCursorScreenPosition([4, 7])
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 1 })
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 2 })
        editor.renderedLines.trigger 'mouseup'
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [5, 24], shiftKey: true, originalEvent: { detail: 3 })
        editor.renderedLines.trigger 'mouseup'
        expect(editor.getSelection().getScreenRange()).toEqual [[4, 7], [5, 30]]

    describe "meta-click", ->
      it "places an additional cursor", ->
        editor.attachToDom()
        setEditorHeightInLines(editor, 5)
        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [3, 0])
        editor.scrollTop(editor.lineHeight * 6)

        spyOn(editor, "scrollTo").andCallThrough()

        editor.renderedLines.trigger mousedownEvent(editor: editor, point: [6, 0], metaKey: true)
        expect(editor.scrollTo.callCount).toBe 1

        [cursor1, cursor2] = editor.getCursorViews()
        expect(cursor1.position()).toEqual(top: 3 * editor.lineHeight, left: 0)
        expect(cursor1.getBufferPosition()).toEqual [3, 0]
        expect(cursor2.position()).toEqual(top: 6 * editor.lineHeight, left: 0)
        expect(cursor2.getBufferPosition()).toEqual [6, 0]

    describe "click and drag", ->
      it "creates a selection from the initial click to mouse cursor's location ", ->
        editor.attachToDom()
        editor.css(position: 'absolute', top: 10, left: 10)
