11describe ( '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 ;
33
44 var downEvent , upEvent , clickEvent ;
55
@@ -25,7 +25,7 @@ describe('uiGridHeaderCell', function () {
2525
2626 beforeEach ( module ( 'ui.grid' ) ) ;
2727
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_ ) {
2929 $scope = $rootScope ;
3030 $compile = _$compile_ ;
3131 $document = _$document_ ;
@@ -34,6 +34,7 @@ describe('uiGridHeaderCell', function () {
3434 $animate = _$animate_ ;
3535 uiGridConstants = _uiGridConstants_ ;
3636 gridUtil = _gridUtil_ ;
37+ $httpBackend = _$httpBackend_ ;
3738
3839 // Decide whether to use mouse or touch events based on which capabilities the browser has
3940 if ( gridUtil . isTouchEnabled ( ) ) {
@@ -199,4 +200,21 @@ describe('uiGridHeaderCell', function () {
199200 } ) ;
200201 } ) ;
201202
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+ } ) ;
202220} ) ;
0 commit comments