Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
test for #134
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-PatrickOFriel committed Dec 14, 2015
1 parent c0d18f0 commit 851c84d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion js/sky/src/grids/grids.js
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ reloading the grid with the current data after the event has fired.
handleTableWrapperResize();
});

// Reinitialize grid when grid element resizes
// Reinitialize grid when grid element resizes from 0
$scope.$watch(function () {
return element.width();
}, function (newValue, oldValue) {
Expand Down
29 changes: 9 additions & 20 deletions js/sky/src/grids/test/grids.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1402,38 +1402,27 @@ describe('Grid directive', function () {
});

it('reinitializes grid when grid element width changes from 0', function () {
var expectedScrollbarWidth,
tableWrapperEl,
topScrollbarEl,
var columnHeaderEls,
topScrollbarDivEl,
gridWrapperHtml = '<div style="width: 600px;"><bb-grid ng-show="locals.isVisible" bb-grid-options="locals.gridOptions"></bb-grid></div>';

locals.gridOptions.columns[0].width_all = 600;
gridWrapperHtml = '<div class="bb-test-grid" style="width:0px;"><bb-grid bb-grid-options="locals.gridOptions"></bb-grid></div>';

locals.gridOptions.columns[0].width_all = 5;
locals.gridOptions.columns[1].width_all = 5;
locals.gridOptions.columns[2].width_all = 5;

el = setUpGrid(gridWrapperHtml, locals);

spyOn($.fn, 'setGridWidth');

tableWrapperEl = getTableWrapperEl(el);

tableWrapperEl.width(599);

windowEl.trigger('resize');
$('.bb-test-grid').width(600);

expect($.fn.setGridWidth).toHaveBeenCalledWith(610);
$scope.$digest();

topScrollbarEl = el.find('.bb-grid-container .bb-grid-toolbar-container .bb-grid-top-scrollbar');
topScrollbarDivEl = topScrollbarEl.find('div');
columnHeaderEls = getHeaders(el);

expect(topScrollbarDivEl[0].style.width).toBe('610px');
expectedScrollbarWidth = bbWindow.getScrollbarWidth();
topScrollbarDivEl = el.find('.bb-grid-container .bb-grid-toolbar-container .bb-grid-top-scrollbar div');

expect(topScrollbarDivEl[0].style.height).toBe(expectedScrollbarWidth + 'px');
expect(topScrollbarDivEl[0].style.width).toBe('600px');

expect(topScrollbarEl[0].style.height).toBe(expectedScrollbarWidth + 'px');
expect(topScrollbarEl[0].style.width).toBe('599px');
});

it('sets the total column width when no extended column and totalcolumn width exactly the same as the tablewrapperwidth', function () {
Expand Down

0 comments on commit 851c84d

Please sign in to comment.