Add linting support, and, well, lint.

This commit is contained in:
Shruti B Iyer
2017-06-12 16:55:14 +01:00
committed by Dave Page
parent 659eb1c1e8
commit 3f4f8b9e77
31 changed files with 429 additions and 405 deletions

View File

@@ -7,16 +7,17 @@
//
//////////////////////////////////////////////////////////////
import $ from "jquery";
import SlickGrid from "slickgrid.grid";
import XCellSelectionModel from "sources/selection/xcell_selection_model";
import CellSelector from "sources/slickgrid/cell_selector";
import RangeSelectionHelper from "sources/selection/range_selection_helper";
import $ from 'jquery';
import Slick from 'slickgrid';
import 'slickgrid.grid';
import XCellSelectionModel from 'sources/selection/xcell_selection_model';
import CellSelector from 'sources/slickgrid/cell_selector';
import RangeSelectionHelper from 'sources/selection/range_selection_helper';
describe("CellSelector", function () {
describe('CellSelector', function () {
var container, columns, cellSelector, data, cellSelectionModel, grid;
beforeEach(function () {
container = $("<div></div>");
container = $('<div></div>');
container.height(9999);
container.width(9999);
columns = [{
@@ -39,17 +40,17 @@ describe("CellSelector", function () {
grid.registerPlugin(cellSelector);
grid.invalidate();
$("body").append(container);
$('body').append(container);
});
afterEach(function () {
$("body").find(container).remove();
$('body').find(container).remove();
});
describe("when the user clicks or tabs to a cell", function () {
it("sets the selected range to that cell", function () {
describe('when the user clicks or tabs to a cell', function () {
it('sets the selected range to that cell', function () {
var row = 1, column = 0;
$(container.find(".slick-row .slick-cell.l" + column)[row]).click();
$(container.find('.slick-row .slick-cell.l' + column)[row]).click();
var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1);
@@ -59,14 +60,14 @@ describe("CellSelector", function () {
expect(selectedRanges[0].toRow).toBe(1);
});
it("deselects previously selected ranges", function () {
it('deselects previously selected ranges', function () {
var row2Range = RangeSelectionHelper.rangeForRow(grid, 2);
var ranges = RangeSelectionHelper.addRange(cellSelectionModel.getSelectedRanges(),
row2Range);
cellSelectionModel.setSelectedRanges(ranges);
var row = 4, column = 1;
$(container.find(".slick-row .slick-cell.l" + column)[row]).click();
$(container.find('.slick-row .slick-cell.l' + column)[row]).click();
expect(RangeSelectionHelper.isRangeSelected(cellSelectionModel.getSelectedRanges(), row2Range))
.toBe(false);

View File

@@ -13,10 +13,10 @@ import RangeSelectionHelper from 'sources/selection/range_selection_helper';
import XCellSelectionModel from 'sources/selection/xcell_selection_model';
import Slick from 'slickgrid';
import 'slickgrid.grid';
import $ from 'jquery';
describe('#handleQueryOutputKeyboardEvent', function () {
var event, view, grid, slickEvent;
var event, grid, slickEvent;
var SlickGrid = Slick.Grid;
var handleQueryOutputKeyboardEvent;
@@ -27,7 +27,7 @@ describe('#handleQueryOutputKeyboardEvent', function () {
metaKey: false,
which: -1,
keyCode: -1,
preventDefault: jasmine.createSpy('preventDefault')
preventDefault: jasmine.createSpy('preventDefault'),
};
var data = [['', '0,0-cell-content', '0,1-cell-content'],
@@ -35,22 +35,20 @@ describe('#handleQueryOutputKeyboardEvent', function () {
['', '2,0-cell-content', '2,1-cell-content']];
var columnDefinitions = [{name: 'checkboxColumn'}, {pos: 1, name: 'firstColumn'}, {
pos: 2,
name: 'secondColumn'
name: 'secondColumn',
}];
grid = new SlickGrid($('<div></div>'), data, columnDefinitions);
grid.setSelectionModel(new XCellSelectionModel());
slickEvent = {
grid: grid
grid: grid,
};
view = {};
spyOn(clipboard, 'copyTextToClipboard');
handleQueryOutputKeyboardEvent = HandleQueryOutputKeyboardEvent.bind(window);
debugger
});
describe("when a range is selected", function () {
describe('when a range is selected', function () {
beforeEach(function () {
grid.getSelectionModel().setSelectedRanges([
RangeSelectionHelper.rangeForRow(grid, 0),
@@ -58,39 +56,39 @@ describe('#handleQueryOutputKeyboardEvent', function () {
]);
});
describe("pressing Command + C", function () {
describe('pressing Command + C', function () {
beforeEach(function () {
event.metaKey = true;
event.keyCode = 67;
});
it("copies the cell content to the clipboard", function () {
it('copies the cell content to the clipboard', function () {
handleQueryOutputKeyboardEvent(event, slickEvent);
expect(clipboard.copyTextToClipboard).toHaveBeenCalledWith("'0,0-cell-content','0,1-cell-content'\n'2,0-cell-content','2,1-cell-content'");
expect(clipboard.copyTextToClipboard).toHaveBeenCalledWith('\'0,0-cell-content\',\'0,1-cell-content\'\n\'2,0-cell-content\',\'2,1-cell-content\'');
});
});
describe("pressing Ctrl + C", function () {
describe('pressing Ctrl + C', function () {
beforeEach(function () {
event.ctrlKey = true;
event.keyCode = 67;
});
it("copies the cell content to the clipboard", function () {
it('copies the cell content to the clipboard', function () {
handleQueryOutputKeyboardEvent(event, slickEvent);
expect(clipboard.copyTextToClipboard).toHaveBeenCalledWith("'0,0-cell-content','0,1-cell-content'\n'2,0-cell-content','2,1-cell-content'");
expect(clipboard.copyTextToClipboard).toHaveBeenCalledWith('\'0,0-cell-content\',\'0,1-cell-content\'\n\'2,0-cell-content\',\'2,1-cell-content\'');
});
});
describe("pressing Command + A", function () {
describe('pressing Command + A', function () {
beforeEach(function () {
event.metaKey = true;
event.keyCode = 65;
});
it("selects the entire grid to ranges", function () {
it('selects the entire grid to ranges', function () {
handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
@@ -98,13 +96,13 @@ describe('#handleQueryOutputKeyboardEvent', function () {
});
});
describe("pressing Ctrl + A", function () {
describe('pressing Ctrl + A', function () {
beforeEach(function () {
event.ctrlKey = true;
event.keyCode = 65;
});
it("selects the entire grid to ranges", function () {
it('selects the entire grid to ranges', function () {
handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
@@ -113,14 +111,14 @@ describe('#handleQueryOutputKeyboardEvent', function () {
});
});
describe("when no ranges are selected", function () {
describe("pressing Command + A", function () {
describe('when no ranges are selected', function () {
describe('pressing Command + A', function () {
beforeEach(function () {
event.metaKey = true;
event.keyCode = 65;
});
it("selects the entire grid to ranges", function () {
it('selects the entire grid to ranges', function () {
handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
@@ -128,13 +126,13 @@ describe('#handleQueryOutputKeyboardEvent', function () {
});
});
describe("pressing Ctrl + A", function () {
describe('pressing Ctrl + A', function () {
beforeEach(function () {
event.ctrlKey = true;
event.keyCode = 65;
});
it("selects the entire grid to ranges", function () {
it('selects the entire grid to ranges', function () {
handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();