           atom.commands.dispatch(editor.element, 'core:confirm')
 
         it 'closes the editor', ->
-          expect(tableView.find('atom-text-editor:visible').length).toEqual(0)
+          expect(tableElement.find('atom-text-editor:visible').length).toEqual(0)
 
         it 'gives the focus back to the table view', ->
-          expect(tableView.hiddenInput.is(':focus')).toBeTruthy()
+          expect(tableElement.hiddenInput.is(':focus')).toBeTruthy()
 
         it 'changes the cell value', ->
-          expect(tableView.getActiveCell().getValue()).toEqual('foobar')
+          expect(tableElement.getActiveCell().getValue()).toEqual('foobar')
 
       describe 'when the content of the editor did not changed', ->
         beforeEach ->
-          spyOn(tableView.getActiveCell(), 'setValue').andCallThrough()
+          spyOn(tableElement.getActiveCell(), 'setValue').andCallThrough()
           atom.commands.dispatch(editor.element, 'core:confirm')
 
         it 'closes the editor', ->
-          expect(tableView.find('atom-text-editor:visible').length).toEqual(0)
+          expect(tableElement.find('atom-text-editor:visible').length).toEqual(0)
 
         it 'gives the focus back to the table view', ->
-          expect(tableView.hiddenInput.is(':focus')).toBeTruthy()
+          expect(tableElement.hiddenInput.is(':focus')).toBeTruthy()
 
         it 'leaves the cell value as is', ->
-          expect(tableView.getActiveCell().getValue()).toEqual('row0')
-          expect(tableView.getActiveCell().setValue).not.toHaveBeenCalled()
+          expect(tableElement.getActiveCell().getValue()).toEqual('row0')
+          expect(tableElement.getActiveCell().setValue).not.toHaveBeenCalled()
 
     describe 'clicking on another cell', ->
       beforeEach ->
-        cell = tableView.find('.table-edit-row:nth-child(4) .table-edit-cell:last-child')
+        cell = tableElement.find('.table-edit-row:nth-child(4) .table-edit-cell:last-child')
         mousedown(cell)
 
       it 'closes the editor', ->
-        expect(tableView.isEditing()).toBeFalsy()
+        expect(tableElement.isEditing()).toBeFalsy()
 
   #     ######  ######## ##       ########  ######  ########
   #    ##    ## ##       ##       ##       ##    ##    ##

      atom.config.set 'table-edit.pageMovesAmount', 20

    it 'moves the active cell 20 rows below', ->
      atom.commands.dispatch(tableView.element, 'core:page-down')

      expect(tableView.activeCellPosition.row).toEqual(20)

    it 'stops to the last row without looping', ->
      tableView.activeCellPosition.row = 90

      atom.commands.dispatch(tableView.element, 'core:page-down')

      expect(tableView.activeCellPosition.row).toEqual(99)

    describe 'with a custom amount on the instance', ->
      it 'moves the active cell 30 rows below', ->
        tableView.pageMovesAmount = 30

        atom.commands.dispatch(tableView.element, 'core:page-down')

        expect(tableView.activeCellPosition.row).toEqual(30)

      it 'keeps using its own amount even when the config change', ->
        tableView.pageMovesAmount = 30
        atom.config.set 'table-edit.pageMovesAmount', 50

        atom.commands.dispatch(tableView.element, 'core:page-down')

        expect(tableView.activeCellPosition.row).toEqual(30)

  describe 'core:page-up', ->
    beforeEach ->
      atom.config.set 'table-edit.pageMovesAmount', 20

    it 'moves the active cell 20 rows up', ->
      tableView.activeCellPosition.row = 20

      atom.commands.dispatch(tableView.element, 'core:page-up')

      expect(tableView.activeCellPosition.row).toEqual(0)

    it 'stops to the first cell without looping', ->
      tableView.activeCellPosition.row = 10

      atom.commands.dispatch(tableView.element, 'core:page-up')

      expect(tableView.activeCellPosition.row).toEqual(0)

  describe 'core:move-to-top', ->
    beforeEach ->
      atom.config.set 'table-edit.pageMovesAmount', 20

    it 'moves the active cell to the first row', ->
      tableView.activeCellPosition.row = 50

      atom.commands.dispatch(tableView.element, 'core:move-to-top')

      expect(tableView.activeCellPosition.row).toEqual(0)

  describe 'core:move-to-bottom', ->
    beforeEach ->
      atom.config.set 'table-edit.pageMovesAmount', 20

    it 'moves the active cell to the first row', ->
      tableView.activeCellPosition.row = 50

      atom.commands.dispatch(tableView.element, 'core:move-to-bottom')

      expect(tableView.activeCellPosition.row).toEqual(99)

  describe 'table-edit:insert-row-before', ->
    it 'inserts a new row before the active row', ->
      atom.commands.dispatch(tableView.element, 'table-edit:insert-row-before')

      expect(table.getRow(0).getValues()).toEqual([null, null, null])

  describe 'table-edit:insert-row-after', ->
    it 'inserts a new row after the active row', ->
      atom.commands.dispatch(tableView.element, 'table-edit:insert-row-after')

      expect(table.getRow(1).getValues()).toEqual([null, null, null])

  describe 'table-edit:delete-row', ->
    it 'deletes the current active row', ->
      mockConfirm(0)
      atom.commands.dispatch(tableView.element, 'table-edit:delete-row')

      expect(table.getRow(0).getValues()).toEqual(['row1', 100, 'no'])

    it 'asks for a confirmation', ->
      mockConfirm(0)
      atom.commands.dispatch(tableView.element, 'table-edit:delete-row')

      expect(atom.confirm).toHaveBeenCalled()

    it 'does not remove the row when cancelled', ->
      mockConfirm(1)
      atom.commands.dispatch(tableView.element, 'table-edit:delete-row')

      expect(table.getRow(0).getValues()).toEqual(['row0', 0, 'yes'])

    describe 'when the deleted row has a custom height', ->
      beforeEach ->
        spyOn(tableView, 'computeRowOffsets')
        tableView.setRowHeightAt(0, 100)
        mockConfirm(0)

      it 'removes the height entry', ->
        atom.commands.dispatch(tableView.element, 'table-edit:delete-row')

        expect(tableView.getRowHeightAt(0)).toEqual(20)

      it 'updates the rows offsets', ->
        expect(tableView.computeRowOffsets).toHaveBeenCalled()

  describe 'table-edit:insert-column-before', ->
    it 'inserts a new column before the active column', ->
      atom.commands.dispatch(tableView.element, 'table-edit:insert-column-before')

      expect(table.getRow(0).getValues()).toEqual([null, 'row0', 0, 'yes'])

    it 'adjusts the columns width and keeps proportions of the initial columns', ->
      tableView.setColumnsWidths([0.1, 0.1, 0.8])
      atom.commands.dispatch(tableView.element, 'table-edit:insert-column-before')

      compareCloseArrays(tableView.getColumnsWidths(), [0.2, 0.08, 0.08, 0.64])

    describe 'called several times', ->
      it 'creates incremental names for columns', ->
        atom.commands.dispatch(tableView.element, 'table-edit:insert-column-before')
        atom.commands.dispatch(tableView.element, 'table-edit:insert-column-before')

        expect(table.getColumn(0).name).toEqual('untitled_1')
        expect(table.getColumn(1).name).toEqual('untitled_0')

  describe 'table-edit:insert-column-after', ->
    it 'inserts a new column after the active column', ->
      atom.commands.dispatch(tableView.element, 'table-edit:insert-column-after')

      expect(table.getRow(0).getValues()).toEqual(['row0', null, 0, 'yes'])

    it 'adjusts the columns width and keeps proportions of the initial columns', ->
      tableView.setColumnsWidths([0.1, 0.1, 0.8])
      atom.commands.dispatch(tableView.element, 'table-edit:insert-column-after')

      compareCloseArrays(tableView.getColumnsWidths(), [0.08, 0.2, 0.08, 0.64])

    describe 'called several times', ->
      it 'creates incremental names for columns', ->
        atom.commands.dispatch(tableView.element, 'table-edit:insert-column-after')
        atom.commands.dispatch(tableView.element, 'table-edit:insert-column-after')

        expect(table.getColumn(1).name).toEqual('untitled_1')
        expect(table.getColumn(2).name).toEqual('untitled_0')

    it 'renders undefined cells based on a config', ->
      atom.config.set('table-edit.undefinedDisplay', 'foo')

      tableElement.getActiveCell().setValue(undefined)
      nextAnimationFrame()
      expect(cells.first().text()).toEqual('foo')

    it 'renders undefined cells based on the view property', ->
      tableElement.undefinedDisplay = 'bar'
      atom.config.set('table-edit.undefinedDisplay', 'foo')

      tableElement.getActiveCell().setValue(undefined)
      nextAnimationFrame()
      expect(cells.first().text()).toEqual('bar')

    it 'sets the proper height on the table body content', ->
      bodyContent = tableElement.find('.table-edit-content')

      expect(bodyContent.outerHeight()).toBeCloseTo(2000)

    it 'sets the proper width and height on the table rows container', ->
      bodyContent = tableElement.find('.table-edit-rows')

      expect(bodyContent.outerHeight()).toBeCloseTo(2000)
      expect(bodyContent.outerWidth()).toBeCloseTo(tableElement.width(), -1)

    describe 'with the absolute widths setting enabled', ->
      beforeEach ->
        tableElement.setAbsoluteColumnsWidths(true)
        nextAnimationFrame()

        row = tableElement.find('.table-edit-row').first()
        cells = row.find('.table-edit-cell')

      describe 'without any columns layout data', ->
