1
- jest . mock ( '@slickgrid-universal/common/dist/commonjs/formatters/formatterUtilities' ) ;
2
1
import 'jest-extended' ;
3
2
import { ApplicationRef , ChangeDetectorRef , ElementRef } from '@angular/core' ;
4
3
import { TestBed } from '@angular/core/testing' ;
5
4
import { TranslateService , TranslateModule } from '@ngx-translate/core' ;
6
5
import {
6
+ autoAddEditorFormatterToColumnsWithEditor ,
7
7
BackendService ,
8
8
BackendServiceApi ,
9
9
BackendUtilityService ,
@@ -39,7 +39,6 @@ import {
39
39
TreeDataService ,
40
40
SlickGroupItemMetadataProvider
41
41
} from '@slickgrid-universal/common' ;
42
- import * as formatterUtilities from '@slickgrid-universal/common/dist/commonjs/formatters/formatterUtilities' ;
43
42
import { SlickFooterComponent } from '@slickgrid-universal/custom-footer-component' ;
44
43
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub' ;
45
44
import { SlickEmptyWarningComponent } from '@slickgrid-universal/empty-warning-component' ;
@@ -54,6 +53,11 @@ import { GridOption } from '../../models';
54
53
import { MockSlickEvent , MockSlickEventHandler } from '../../../../../../test/mockSlickEvent' ;
55
54
import { RxJsResourceStub } from '../../../../../../test/rxjsResourceStub' ;
56
55
56
+ jest . mock ( '@slickgrid-universal/common' , ( ) => ( {
57
+ ...( jest . requireActual ( '@slickgrid-universal/common' ) as any ) ,
58
+ autoAddEditorFormatterToColumnsWithEditor : jest . fn ( ) ,
59
+ } ) ) ;
60
+
57
61
declare const Slick : any ;
58
62
const slickEventHandler = new MockSlickEventHandler ( ) ;
59
63
jest . mock ( 'flatpickr' , ( ) => { } ) ;
@@ -538,7 +542,7 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
538
542
component . ngAfterViewInit ( ) ;
539
543
540
544
expect ( component ) . toBeTruthy ( ) ;
541
- // expect(formatterUtilities. autoAddEditorFormatterToColumnsWithEditor).toHaveBeenCalledWith([{ id: 'name', field: 'name', editor: undefined, internalColumnEditor: {} }], customEditableInputFormatter);
545
+ expect ( autoAddEditorFormatterToColumnsWithEditor ) . toHaveBeenCalledWith ( [ { id : 'name' , field : 'name' , editor : undefined , internalColumnEditor : { } } ] , customEditableInputFormatter ) ;
542
546
} ) ;
543
547
} ) ;
544
548
@@ -565,7 +569,6 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
565
569
const autosizeSpy = jest . spyOn ( mockGrid , 'autosizeColumns' ) ;
566
570
const updateSpy = jest . spyOn ( component , 'updateColumnDefinitionsList' ) ;
567
571
const renderSpy = jest . spyOn ( extensionServiceStub , 'renderColumnHeaders' ) ;
568
- const autoAddFormatterSpy = jest . spyOn ( formatterUtilities , 'autoAddEditorFormatterToColumnsWithEditor' ) ;
569
572
const mockColDefs = [ { id : 'name' , field : 'name' , editor : undefined , internalColumnEditor : { } } ] ;
570
573
571
574
component . ngAfterViewInit ( ) ;
@@ -577,7 +580,7 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
577
580
expect ( autosizeSpy ) . toHaveBeenCalled ( ) ;
578
581
expect ( updateSpy ) . toHaveBeenCalledWith ( mockColDefs ) ;
579
582
expect ( renderSpy ) . toHaveBeenCalledWith ( mockColDefs , true ) ;
580
- // expect(autoAddFormatterSpy ).toHaveBeenCalledWith([{ id: 'name', field: 'name', editor: undefined, internalColumnEditor: {} }], customEditableInputFormatter);
583
+ expect ( autoAddEditorFormatterToColumnsWithEditor ) . toHaveBeenCalledWith ( [ { id : 'name' , field : 'name' , editor : undefined , internalColumnEditor : { } } ] , customEditableInputFormatter ) ;
581
584
} ) ;
582
585
} ) ;
583
586
0 commit comments