Skip to content

Commit 721d0ec

Browse files
Portugal, Marcelomportuga
Portugal, Marcelo
authored andcommitted
test(tree-base.spec): Updating tree-base unit tests.
Also, setting up tree-base to support future performance improvement.
1 parent 3c3264e commit 721d0ec

File tree

2 files changed

+29
-36
lines changed

2 files changed

+29
-36
lines changed

src/features/tree-base/js/tree-base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@
715715
};
716716

717717
rowHeaderColumnDef.visible = grid.options.treeRowHeaderAlwaysVisible;
718-
grid.addRowHeaderColumn( rowHeaderColumnDef, -100 );
718+
grid.addRowHeaderColumn(rowHeaderColumnDef, -100, true);
719719
},
720720

721721

src/features/tree-base/test/tree-base.spec.js

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
describe('ui.grid.treeBase uiGridTreeBaseService', function () {
2-
var uiGridTreeBaseService;
3-
var uiGridTreeBaseConstants;
4-
var gridClassFactory;
5-
var grid;
6-
var $rootScope;
7-
var $scope;
8-
var GridRow;
9-
var gridUtil;
10-
var uiGridConstants;
11-
12-
beforeEach(module('ui.grid.treeBase'));
13-
14-
beforeEach(inject(function (_uiGridTreeBaseService_,_gridClassFactory_, $templateCache, _uiGridTreeBaseConstants_,
15-
_$rootScope_, _GridRow_, _gridUtil_, _uiGridConstants_) {
16-
uiGridTreeBaseService = _uiGridTreeBaseService_;
17-
uiGridTreeBaseConstants = _uiGridTreeBaseConstants_;
18-
gridClassFactory = _gridClassFactory_;
19-
$rootScope = _$rootScope_;
2+
var uiGridTreeBaseService,
3+
uiGridTreeBaseConstants,
4+
gridClassFactory,
5+
grid,
6+
$rootScope,
7+
$scope,
8+
GridRow,
9+
gridUtil,
10+
uiGridConstants;
11+
12+
beforeEach(function() {
13+
module('ui.grid.treeBase');
14+
15+
inject(function (_uiGridTreeBaseService_,_gridClassFactory_, $templateCache, _uiGridTreeBaseConstants_,
16+
_$rootScope_, _GridRow_, _gridUtil_, _uiGridConstants_) {
17+
uiGridTreeBaseService = _uiGridTreeBaseService_;
18+
uiGridTreeBaseConstants = _uiGridTreeBaseConstants_;
19+
gridClassFactory = _gridClassFactory_;
20+
$rootScope = _$rootScope_;
21+
GridRow = _GridRow_;
22+
gridUtil = _gridUtil_;
23+
uiGridConstants = _uiGridConstants_;
24+
});
2025
$scope = $rootScope.$new();
21-
GridRow = _GridRow_;
22-
gridUtil = _gridUtil_;
23-
uiGridConstants = _uiGridConstants_;
2426

2527
grid = gridClassFactory.createGrid({});
2628
grid.options.columnDefs = [
@@ -30,6 +32,7 @@ describe('ui.grid.treeBase uiGridTreeBaseService', function () {
3032
{field: 'col3'}
3133
];
3234

35+
spyOn(grid, 'addRowHeaderColumn').and.callThrough();
3336
uiGridTreeBaseService.initializeGrid(grid, $scope);
3437
$scope.$apply();
3538

@@ -44,24 +47,11 @@ describe('ui.grid.treeBase uiGridTreeBaseService', function () {
4447
data[7].$$treeLevel = 0;
4548
data[9].$$treeLevel = 1;
4649

47-
// data = [
48-
// { col0: 'a_0', col1: 0, col2: 'c_0', col3: 0, '$$treeLevel': 0 } ,
49-
// { col0: 'a_0', col1: 0, col2: 'c_1', col3: 1, '$$treeLevel': 1 },
50-
// { col0: 'a_0', col1: 1, col2: 'c_2', col3: 2 },
51-
// { col0: 'a_0', col1: 1, col2: 'c_3', col3: 3, '$$treeLevel': 1 },
52-
// { col0: 'a_1', col1: 2, col2: 'c_4', col3: 4, '$$treeLevel': 2 },
53-
// { col0: 'a_1', col1: 2, col2: 'c_5', col3: 5 },
54-
// { col0: 'a_1', col1: 3, col2: 'c_6', col3: 6 },
55-
// { col0: 'a_1', col1: 3, col2: 'c_7', col3: 7, '$$treeLevel': 0 },
56-
// { col0: 'a_2', col1: 4, col2: 'c_8', col3: 8 },
57-
// { col0: 'a_2', col1: 4, col2: 'c_9', col3: 9, '$$treeLevel': 1 }
58-
// ];
59-
6050
grid.options.data = data;
6151

6252
grid.buildColumns();
6353
grid.modifyRows(grid.options.data);
64-
}));
54+
});
6555

6656

6757
describe( 'initializeGrid and defaultGridOptions', function() {
@@ -90,6 +80,9 @@ describe('ui.grid.treeBase uiGridTreeBaseService', function () {
9080
enableExpandAll: true
9181
});
9282
});
83+
it('should call addRowHeaderColumn', function() {
84+
expect(grid.addRowHeaderColumn).toHaveBeenCalledWith(jasmine.any(Object), -100, true);
85+
});
9386
});
9487

9588

0 commit comments

Comments
 (0)