@@ -518,10 +518,48 @@ describe('ExtensionService', () => {
518
518
it ( 'should call "setColumns" on the Shared Service with the collection provided as argument' , ( ) => {
519
519
const columnsMock = [ { id : 'field1' , field : 'field1' , headerKey : 'HELLO' } ] as Column [ ] ;
520
520
jest . spyOn ( SharedService . prototype , 'grid' , 'get' ) . mockReturnValue ( gridStub ) ;
521
+ const spyAllCols = jest . spyOn ( SharedService . prototype , 'allColumns' , 'set' ) ;
521
522
const setColumnsSpy = jest . spyOn ( gridStub , 'setColumns' ) ;
522
523
523
524
service . renderColumnHeaders ( columnsMock ) ;
524
525
526
+ expect ( spyAllCols ) . toHaveBeenCalledWith ( columnsMock ) ;
527
+ expect ( setColumnsSpy ) . toHaveBeenCalledWith ( columnsMock ) ;
528
+ } ) ;
529
+
530
+ it ( 'should re-register the Column Picker when enable and method is called with new column definition collection provided as argument' , ( ) => {
531
+ const gridOptionsMock = { enableColumnPicker : true } as GridOption ;
532
+ const columnsMock = [ { id : 'field1' , field : 'field1' , headerKey : 'HELLO' } ] as Column [ ] ;
533
+ jest . spyOn ( SharedService . prototype , 'gridOptions' , 'get' ) . mockReturnValue ( gridOptionsMock ) ;
534
+ jest . spyOn ( SharedService . prototype , 'grid' , 'get' ) . mockReturnValue ( gridStub ) ;
535
+ const spyCpDispose = jest . spyOn ( extensionColumnPickerStub , 'dispose' ) ;
536
+ const spyCpRegister = jest . spyOn ( extensionColumnPickerStub , 'register' ) ;
537
+ const spyAllCols = jest . spyOn ( SharedService . prototype , 'allColumns' , 'set' ) ;
538
+ const setColumnsSpy = jest . spyOn ( gridStub , 'setColumns' ) ;
539
+
540
+ service . renderColumnHeaders ( columnsMock ) ;
541
+
542
+ expect ( spyCpDispose ) . toHaveBeenCalled ( ) ;
543
+ expect ( spyCpRegister ) . toHaveBeenCalled ( ) ;
544
+ expect ( spyAllCols ) . toHaveBeenCalledWith ( columnsMock ) ;
545
+ expect ( setColumnsSpy ) . toHaveBeenCalledWith ( columnsMock ) ;
546
+ } ) ;
547
+
548
+ it ( 'should re-register the Grid Menu when enable and method is called with new column definition collection provided as argument' , ( ) => {
549
+ const gridOptionsMock = { enableGridMenu : true } as GridOption ;
550
+ const columnsMock = [ { id : 'field1' , field : 'field1' , headerKey : 'HELLO' } ] as Column [ ] ;
551
+ jest . spyOn ( SharedService . prototype , 'gridOptions' , 'get' ) . mockReturnValue ( gridOptionsMock ) ;
552
+ jest . spyOn ( SharedService . prototype , 'grid' , 'get' ) . mockReturnValue ( gridStub ) ;
553
+ const spyGmDispose = jest . spyOn ( extensionGridMenuStub , 'dispose' ) ;
554
+ const spyGmRegister = jest . spyOn ( extensionGridMenuStub , 'register' ) ;
555
+ const spyAllCols = jest . spyOn ( SharedService . prototype , 'allColumns' , 'set' ) ;
556
+ const setColumnsSpy = jest . spyOn ( gridStub , 'setColumns' ) ;
557
+
558
+ service . renderColumnHeaders ( columnsMock ) ;
559
+
560
+ expect ( spyGmDispose ) . toHaveBeenCalled ( ) ;
561
+ expect ( spyGmRegister ) . toHaveBeenCalled ( ) ;
562
+ expect ( spyAllCols ) . toHaveBeenCalledWith ( columnsMock ) ;
525
563
expect ( setColumnsSpy ) . toHaveBeenCalledWith ( columnsMock ) ;
526
564
} ) ;
527
565
} ) ;
0 commit comments