@@ -622,6 +622,149 @@ describe('GridColumn factory', function () {
622622 expect ( updateCol ( col , colDef ) ) . toThrow ( ) ;
623623 } ) ;
624624
625+ describe ( 'cellTooltip' , function ( ) {
626+ it ( 'should be set to false when it is undefined' , function ( ) {
627+ colDef . cellTooltip = undefined ;
628+ col . updateColumnDef ( colDef ) ;
629+ expect ( col . cellTooltip ) . toBe ( false ) ;
630+ } ) ;
631+ it ( 'should stay false when the user passed false' , function ( ) {
632+ colDef . cellTooltip = false ;
633+ col . updateColumnDef ( colDef ) ;
634+ expect ( col . cellTooltip ) . toBe ( false ) ;
635+ } ) ;
636+ it ( 'should be set to a function that calls grid.getCellValue when it is set to true' , function ( ) {
637+ colDef . cellTooltip = true ;
638+ col . updateColumnDef ( colDef ) ;
639+ expect ( angular . isFunction ( col . cellTooltip ) ) . toBe ( true ) ;
640+
641+ spyOn ( col . grid , 'getCellValue' ) . and . callFake ( angular . noop ) ;
642+ col . cellTooltip ( null , col ) ;
643+
644+ expect ( col . grid . getCellValue ) . toHaveBeenCalled ( ) ;
645+
646+ col . grid . getCellValue . calls . reset ( ) ;
647+ } ) ;
648+ it ( 'should be assigned to whatever function is passed to it' , function ( ) {
649+ colDef . cellTooltip = angular . noop ;
650+ col . updateColumnDef ( colDef ) ;
651+ expect ( angular . isFunction ( col . cellTooltip ) ) . toBe ( true ) ;
652+ expect ( col . cellTooltip ) . toEqual ( colDef . cellTooltip ) ;
653+ } ) ;
654+ it ( 'should be set to a function that returns the string passed into it when it is set to a string' , function ( ) {
655+ colDef . cellTooltip = 'MockHeaderTooltip' ;
656+ col . updateColumnDef ( colDef ) ;
657+ expect ( angular . isFunction ( col . cellTooltip ) ) . toBe ( true ) ;
658+ expect ( col . cellTooltip ( null , col ) ) . toEqual ( colDef . cellTooltip ) ;
659+ } ) ;
660+ } ) ;
661+
662+ describe ( 'headerTooltip' , function ( ) {
663+ it ( 'should be set to false when it is undefined' , function ( ) {
664+ colDef . headerTooltip = undefined ;
665+ col . updateColumnDef ( colDef ) ;
666+ expect ( col . headerTooltip ) . toBe ( false ) ;
667+ } ) ;
668+ it ( 'should stay false when the user passed false' , function ( ) {
669+ colDef . headerTooltip = false ;
670+ col . updateColumnDef ( colDef ) ;
671+ expect ( col . headerTooltip ) . toBe ( false ) ;
672+ } ) ;
673+ it ( 'should be set to a function that returns the display name when it is set to true' , function ( ) {
674+ colDef . headerTooltip = true ;
675+ col . updateColumnDef ( colDef ) ;
676+ expect ( angular . isFunction ( col . headerTooltip ) ) . toBe ( true ) ;
677+ expect ( col . headerTooltip ( col ) ) . toEqual ( col . displayName ) ;
678+ } ) ;
679+ it ( 'should be assigned to whatever function is passed to it' , function ( ) {
680+ colDef . headerTooltip = angular . noop ;
681+ col . updateColumnDef ( colDef ) ;
682+ expect ( angular . isFunction ( col . headerTooltip ) ) . toBe ( true ) ;
683+ expect ( col . headerTooltip ) . toEqual ( colDef . headerTooltip ) ;
684+ } ) ;
685+ it ( 'should be set to a function that returns the string passed into it when it is set to a string' , function ( ) {
686+ colDef . headerTooltip = 'MockHeaderTooltip' ;
687+ col . updateColumnDef ( colDef ) ;
688+ expect ( angular . isFunction ( col . headerTooltip ) ) . toBe ( true ) ;
689+ expect ( col . headerTooltip ( col ) ) . toEqual ( colDef . headerTooltip ) ;
690+ } ) ;
691+ } ) ;
692+
693+ describe ( 'sortCellFiltered' , function ( ) {
694+ it ( 'should set sortCellFiltered to true when the user passes in a truthy value' , function ( ) {
695+ colDef . sortCellFiltered = 1 ;
696+ col . updateColumnDef ( colDef ) ;
697+
698+ expect ( col . sortCellFiltered ) . toBe ( true ) ;
699+ } ) ;
700+ it ( 'should set sortCellFiltered to false when the user passes in a falsy value' , function ( ) {
701+ colDef . sortCellFiltered = 0 ;
702+ col . updateColumnDef ( colDef ) ;
703+
704+ expect ( col . sortCellFiltered ) . toBe ( false ) ;
705+ } ) ;
706+ } ) ;
707+
708+ describe ( 'filterCellFiltered' , function ( ) {
709+ it ( 'should set filterCellFiltered to true when the user passes in a truthy value' , function ( ) {
710+ colDef . filterCellFiltered = 'yes' ;
711+ col . updateColumnDef ( colDef ) ;
712+
713+ expect ( col . filterCellFiltered ) . toBe ( true ) ;
714+ } ) ;
715+ it ( 'should set filterCellFiltered to false when the user passes in a falsy value' , function ( ) {
716+ colDef . filterCellFiltered = null ;
717+ col . updateColumnDef ( colDef ) ;
718+
719+ expect ( col . filterCellFiltered ) . toBe ( false ) ;
720+ } ) ;
721+ } ) ;
722+
723+ describe ( 'footerCellFilter' , function ( ) {
724+ it ( 'should set footerCellFilter to the value passed in by the user when the user passes in a truthy value' , function ( ) {
725+ colDef . footerCellFilter = 'date' ;
726+ col . updateColumnDef ( colDef ) ;
727+
728+ expect ( col . footerCellFilter ) . toEqual ( colDef . footerCellFilter ) ;
729+ } ) ;
730+ it ( 'should set footerCellFilter an empty string when the user passes in a falsy value' , function ( ) {
731+ colDef . footerCellFilter = null ;
732+ col . updateColumnDef ( colDef ) ;
733+
734+ expect ( col . footerCellFilter ) . toEqual ( '' ) ;
735+ } ) ;
736+ } ) ;
737+
738+ describe ( 'sortDirectionCycle' , function ( ) {
739+ it ( 'should set sortDirectionCycle to the value passed in by the user when the user passes in a truthy value' , function ( ) {
740+ colDef . sortDirectionCycle = [ uiGridConstants . ASC , uiGridConstants . DESC ] ;
741+ col . updateColumnDef ( colDef ) ;
742+
743+ expect ( col . sortDirectionCycle ) . toEqual ( colDef . sortDirectionCycle ) ;
744+ } ) ;
745+ it ( 'should set sortDirectionCycle the default value when the user passes in undefined' , function ( ) {
746+ colDef . sortDirectionCycle = undefined ;
747+ col . updateColumnDef ( colDef ) ;
748+
749+ expect ( col . sortDirectionCycle ) . toEqual ( [ null , uiGridConstants . ASC , uiGridConstants . DESC ] ) ;
750+ } ) ;
751+ } ) ;
752+
753+ describe ( 'enableFiltering' , function ( ) {
754+ it ( 'should set enableFiltering to the value passed by the user when that value is not undefined' , function ( ) {
755+ colDef . enableFiltering = false ;
756+ col . updateColumnDef ( colDef ) ;
757+
758+ expect ( col . enableFiltering ) . toEqual ( colDef . enableFiltering ) ;
759+ } ) ;
760+ it ( 'should set enableFiltering to true when the user passes in undefined' , function ( ) {
761+ colDef . enableFiltering = undefined ;
762+ col . updateColumnDef ( colDef ) ;
763+
764+ expect ( col . enableFiltering ) . toBe ( true ) ;
765+ } ) ;
766+ } ) ;
767+
625768 function widthEqualsColDefWidth ( expected ) {
626769 return function ( ) {
627770 colDef . width = expected ;
@@ -653,4 +796,42 @@ describe('GridColumn factory', function () {
653796 } ;
654797 }
655798 } ) ;
799+
800+ describe ( 'isPinnedLeft' , function ( ) {
801+ var col ;
802+
803+ beforeEach ( function ( ) {
804+ col = grid . columns [ 0 ] ;
805+ } ) ;
806+
807+ it ( 'should return true when the column is on the left render container' , function ( ) {
808+ col . renderContainer = 'left' ;
809+
810+ expect ( col . isPinnedLeft ( ) ) . toBe ( true ) ;
811+ } ) ;
812+ it ( 'should return false when the column is not on the left render container' , function ( ) {
813+ col . renderContainer = 'right' ;
814+
815+ expect ( col . isPinnedLeft ( ) ) . toBe ( false ) ;
816+ } ) ;
817+ } ) ;
818+
819+ describe ( 'isPinnedRight' , function ( ) {
820+ var col ;
821+
822+ beforeEach ( function ( ) {
823+ col = grid . columns [ 0 ] ;
824+ } ) ;
825+
826+ it ( 'should return true when the column is on the right render container' , function ( ) {
827+ col . renderContainer = 'right' ;
828+
829+ expect ( col . isPinnedRight ( ) ) . toBe ( true ) ;
830+ } ) ;
831+ it ( 'should return false when the column is not on the right render container' , function ( ) {
832+ col . renderContainer = 'left' ;
833+
834+ expect ( col . isPinnedRight ( ) ) . toBe ( false ) ;
835+ } ) ;
836+ } ) ;
656837} ) ;
0 commit comments