Skip to content

Commit

Permalink
fix: 🐛 address linting issues and unit test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelo-portugal committed Aug 1, 2021
1 parent 29d4803 commit a9cf59f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/js/factories/GridRenderContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,12 @@ angular.module('ui.grid')
var wholeLeftWidth = 0;
var index = 0
for (index; index < this.visibleColumnCache.length; index++) {
if(this.visibleColumnCache[index] && this.visibleColumnCache[index].visible){
//accumulate the whole width of columns on the left side, till the point of visibility is surpassed, this is our wanted index
if (this.visibleColumnCache[index] && this.visibleColumnCache[index].visible) {
// accumulate the whole width of columns on the left side, till the point of visibility is surpassed, this is our wanted index
wholeLeftWidth += this.visibleColumnCache[index].drawnWidth;
if(wholeLeftWidth >= scrollLeft)
if (wholeLeftWidth >= scrollLeft) {
break;
}
}
}
return index;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/js/services/rowSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ module.service('rowSearcher', ['gridUtil', 'uiGridConstants', function (gridUtil

var term = rowSearcher.getTerm(filter);

if (/\*/.test(term)) {//this would check only start and end -> /^\*|\*$/
if (/\*/.test(term)) {// this would check only start and end -> /^\*|\*$/
var regexpFlags = (!filter.flags || !filter.flags.caseSensitive) ? 'i' : '';
term = escapeRegExp(term);
var reText = term.replace(/\\\*/g, '.*?');//this would check only start and end -> /^\\\*|\\\*$/g
var reText = term.replace(/\\\*/g, '.*?');// this would check only start and end -> /^\\\*|\\\*$/g
return new RegExp('^' + reText + '$', regexpFlags);
}
// Otherwise default to default condition
Expand Down
19 changes: 6 additions & 13 deletions packages/core/test/core/factories/Grid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,10 +1181,9 @@ describe('Grid factory', function() {
null
);
});
it('should call adjust columns with null for a scroll percentage and the prevScrollLeft value', function() {
it('should call adjust columns with the prevScrollLeft value', function() {
expect(grid.renderContainers.body.adjustColumns).toHaveBeenCalledWith(
grid.renderContainers.body.prevScrollLeft,
null
grid.renderContainers.body.prevScrollLeft
);
});
});
Expand All @@ -1197,13 +1196,10 @@ describe('Grid factory', function() {
null
);
});
it('should call adjust columns with null for a scroll percentage and the prevScrollLeft value if prevScrollLeft is greater than 0', function() {
it('should call adjust columns with the prevScrollLeft value if prevScrollLeft is greater than 0', function() {
grid.renderContainers.body.prevScrollLeft = 20;
grid.redrawInPlace(false);
expect(grid.renderContainers.body.adjustColumns).toHaveBeenCalledWith(
grid.renderContainers.body.prevScrollLeft,
null
);
expect(grid.renderContainers.body.adjustColumns).toHaveBeenCalledWith(grid.renderContainers.body.prevScrollLeft);
});
it('should call adjust rows with null for a scroll top and the scroll percentage value if prevScrollTop is less or equal to 0', function() {
grid.renderContainers.body.prevScrollTop = 0;
Expand All @@ -1214,15 +1210,12 @@ describe('Grid factory', function() {
grid.renderContainers.body.prevScrolltopPercentage
);
});
it('should call adjust columns with null for a scroll left and the scroll percentage value if prevScrollLeft is less or equal to 0',
it('should call adjust columns with null for a scroll left if prevScrollLeft is less or equal to 0',
function() {
grid.renderContainers.body.prevScrollLeft = 0;
grid.renderContainers.body.prevScrollleftPercentage = 40;
grid.redrawInPlace(false);
expect(grid.renderContainers.body.adjustColumns).toHaveBeenCalledWith(
null,
grid.renderContainers.body.prevScrollleftPercentage
);
expect(grid.renderContainers.body.adjustColumns).toHaveBeenCalledWith(null);
});
});
});
Expand Down
17 changes: 6 additions & 11 deletions packages/core/test/core/row-filtering.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
describe('rowSearcher', function() {
var grid, $scope, $compile, recompile,
rows, columns, rowSearcher, uiGridConstants, filter;
var grid, rows, columns, rowSearcher, uiGridConstants, filter;

beforeEach(module('ui.grid'));

beforeEach(inject(function (_$compile_, $rootScope, _rowSearcher_, Grid, GridRow, GridColumn, _uiGridConstants_) {
$scope = $rootScope;
beforeEach(inject(function (_rowSearcher_, Grid, GridRow, GridColumn, _uiGridConstants_) {
rowSearcher = _rowSearcher_;
uiGridConstants = _uiGridConstants_;

Expand Down Expand Up @@ -40,39 +38,38 @@ describe('rowSearcher', function() {
}

afterEach(function () {
// angular.element(grid).remove();
grid = null;
});

describe('guessCondition', function () {
it('should create a RegExp when term ends with a *', function() {
var filter = { term: 'blah*' };

var re = new RegExp(/^blah[\s\S]*?$/i);
var re = new RegExp(/^blah.*?$/i);

expect(rowSearcher.guessCondition(filter)).toEqual(re);
});

it('should create a RegExp when term starts with a *', function() {
var filter = { term: '*blah' };

var re = new RegExp(/^[\s\S]*?blah$/i);
var re = new RegExp(/^.*?blah$/i);

expect(rowSearcher.guessCondition(filter)).toEqual(re);
});

it('should create a RegExp when term starts and ends with a *', function() {
var filter = { term: '*blah*' };

var re = new RegExp(/^[\s\S]*?blah[\s\S]*?$/i);
var re = new RegExp(/^.*?blah.*?$/i);

expect(rowSearcher.guessCondition(filter)).toEqual(re);
});

it('should create a RegExp when term has a * in the middle', function() {
var filter = { term: 'bl*h' };

var re = new RegExp(/^bl[\s\S]*?h$/i);
var re = new RegExp(/^bl.*?h$/i);

expect(rowSearcher.guessCondition(filter)).toEqual(re);
});
Expand All @@ -82,8 +79,6 @@ describe('rowSearcher', function() {

expect(rowSearcher.guessCondition(filter)).toEqual(uiGridConstants.filter.CONTAINS, 'CONTAINS');
});


});

describe('getTerm', function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/src/js/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@
return $delegate;
}]);
}]);
})();
})();

0 comments on commit a9cf59f

Please sign in to comment.