1
1
describe ( 'uiGridHeaderCell' , function ( ) {
2
- var grid , $scope , $compile , $document , $timeout , $window , recompile , $animate , uiGridConstants , gridUtil , columnDefs ;
2
+ var grid , $scope , $compile , $document , $timeout , $window , recompile , $animate , uiGridConstants , gridUtil , columnDefs , $httpBackend ;
3
3
4
4
var downEvent , upEvent , clickEvent ;
5
5
@@ -25,7 +25,7 @@ describe('uiGridHeaderCell', function () {
25
25
26
26
beforeEach ( module ( 'ui.grid' ) ) ;
27
27
28
- beforeEach ( inject ( function ( _$compile_ , $rootScope , _$document_ , _$timeout_ , _$window_ , _$animate_ , _uiGridConstants_ , _gridUtil_ ) {
28
+ beforeEach ( inject ( function ( _$compile_ , $rootScope , _$document_ , _$timeout_ , _$window_ , _$animate_ , _uiGridConstants_ , _gridUtil_ , _$httpBackend_ ) {
29
29
$scope = $rootScope ;
30
30
$compile = _$compile_ ;
31
31
$document = _$document_ ;
@@ -34,6 +34,7 @@ describe('uiGridHeaderCell', function () {
34
34
$animate = _$animate_ ;
35
35
uiGridConstants = _uiGridConstants_ ;
36
36
gridUtil = _gridUtil_ ;
37
+ $httpBackend = _$httpBackend_ ;
37
38
38
39
// Decide whether to use mouse or touch events based on which capabilities the browser has
39
40
if ( gridUtil . isTouchEnabled ( ) ) {
@@ -199,4 +200,21 @@ describe('uiGridHeaderCell', function () {
199
200
} ) ;
200
201
} ) ;
201
202
203
+ describe ( 'should handle a URL-based template defined in headerCellTemplate' , function ( ) {
204
+ it ( 'should handle' , function ( ) {
205
+ var el , url = 'http://www.a-really-fake-url.com/headerCellTemplate.html' ;
206
+
207
+ $scope . gridOpts . columnDefs [ 0 ] . headerCellTemplate = url ;
208
+
209
+ $httpBackend . expectGET ( url ) . respond ( '<div class="headerCellTemplate">headerCellTemplate content</div>' ) ;
210
+ recompile ( ) ;
211
+
212
+ el = $ ( grid ) . find ( '.headerCellTemplate' ) ;
213
+ expect ( el . text ( ) ) . toEqual ( '' ) ;
214
+
215
+ $httpBackend . flush ( ) ;
216
+ el = $ ( grid ) . find ( '.headerCellTemplate' ) ;
217
+ expect ( el . text ( ) ) . toEqual ( 'headerCellTemplate content' ) ;
218
+ } ) ;
219
+ } ) ;
202
220
} ) ;
0 commit comments