Skip to content

Commit 9b8a383

Browse files
committed
grid scopes wrapping test
1 parent 11f0c1e commit 9b8a383

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

test/GridTestsSpec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,30 @@ describe('uiScroll', function () {
399399

400400
});
401401

402+
describe('scopes wrapping', function () {
403+
var scrollSettings = {
404+
datasource: 'myGridDatasource',
405+
viewportHeight: 120,
406+
itemHeight: 20,
407+
bufferSize: 3,
408+
rowTemplate: '<td ng-repeat="col in columns" ui-scroll-td class="{{col}}">{{item[col]}}</td>'
409+
};
410+
var columns = ['col0', 'col1', 'col2', 'col3'];
411+
412+
it('should work', function () {
413+
runGridTest(scrollSettings,
414+
function(head, body) {
415+
for(var i = 0; i < columns.length; i++) {
416+
expect(getLastRowElement(body, i).innerHTML).toBe(columns[i]);
417+
}
418+
},
419+
{
420+
scope: {
421+
columns: columns
422+
}
423+
}
424+
);
425+
});
426+
});
427+
402428
});

test/scaffolding.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ function createGridHtml (settings) {
2525
'<thead style="display:block">' +
2626
'<tr>';
2727
columns.forEach(col => { html +=
28-
'<th ui-scroll-th class="' + col + '">' + col + '</th>'
28+
'<th ui-scroll-th class="' + col + '">' + col + '</th>';
2929
}); html +=
3030
'</tr>' +
3131
'</thead>' +
3232
'<tbody class="grid">' +
3333
'<tr ui-scroll="item in ' + settings.datasource + '" adapter="adapter">';
34-
columns.forEach(col => { html +=
35-
'<td ui-scroll-td class="' + col + '">{{item.' + col + '}}</td>'
36-
}); html +=
34+
if(settings.rowTemplate) {
35+
html += settings.rowTemplate;
36+
} else {
37+
columns.forEach(col => { html +=
38+
'<td ui-scroll-td class="' + col + '">{{item.' + col + '}}</td>';
39+
});
40+
} html +=
3741
'</tr>' +
3842
'</tbody>' +
3943
'</table>';
@@ -83,6 +87,10 @@ function runGridTest (scrollSettings, run, options) {
8387
var head = angular.element(scroller.children()[0]);
8488
var body = angular.element(scroller.children()[1]);
8589

90+
if(options && options.scope) {
91+
angular.extend(scope, options.scope);
92+
}
93+
8694
$compile(scroller)(scope);
8795

8896
scope.$apply();

0 commit comments

Comments
 (0)