@@ -47,7 +47,7 @@ const gridOptionsMock = {
47
47
useSimpleViewportCalc : true ,
48
48
saveDetailViewOnScroll : false ,
49
49
process : ( ) => new Promise ( ( resolve ) => resolve ( 'process resolved' ) ) ,
50
- viewComponent : null ,
50
+ viewComponent : null as any ,
51
51
onExtensionRegistered : jest . fn ( ) ,
52
52
onAsyncResponse : ( ) => { } ,
53
53
onAsyncEndUpdate : ( ) => { } ,
@@ -309,11 +309,6 @@ describe('SlickRowDetailView', () => {
309
309
plugin . register ( ) ;
310
310
plugin . onBeforeRowDetailToggle . notify ( { item : columnsMock [ 0 ] , grid : gridStub } , new SlickEventData ( ) , gridStub ) ;
311
311
312
- // expect(handlerSpy).toHaveBeenCalledTimes(8); // there are an extra 2x on the grid itself
313
- // expect(handlerSpy).toHaveBeenCalledWith(
314
- // { notify: expect.anything(), subscribe: expect.anything(), unsubscribe: expect.anything(), },
315
- // expect.anything()
316
- // );
317
312
expect ( onAsyncRespSpy ) . not . toHaveBeenCalled ( ) ;
318
313
expect ( onAsyncEndSpy ) . not . toHaveBeenCalled ( ) ;
319
314
expect ( onAfterRowSpy ) . not . toHaveBeenCalled ( ) ;
@@ -656,6 +651,28 @@ describe('SlickRowDetailView', () => {
656
651
expect ( disposeSpy ) . toHaveBeenCalled ( ) ;
657
652
expect ( disposeAllSpy ) . toHaveBeenCalled ( ) ;
658
653
} ) ;
654
+
655
+ it ( 'should call internal event handler subscribe and expect the "onBeforeRowDetailToggle" option to be called and return true when addon notify is called' , ( ) => {
656
+ gridOptionsMock . rowDetailView ! . onBeforeRowDetailToggle = undefined ;
657
+ const onAsyncRespSpy = jest . spyOn ( gridOptionsMock . rowDetailView as RowDetailView , 'onAsyncResponse' ) ;
658
+ const onAsyncEndSpy = jest . spyOn ( gridOptionsMock . rowDetailView as RowDetailView , 'onAsyncEndUpdate' ) ;
659
+ const onAfterRowSpy = jest . spyOn ( gridOptionsMock . rowDetailView as RowDetailView , 'onAfterRowDetailToggle' ) ;
660
+ // const onBeforeRowSpy = jest.spyOn(gridOptionsMock.rowDetailView as RowDetailView, 'onBeforeRowDetailToggle');
661
+ const onRowOutViewSpy = jest . spyOn ( gridOptionsMock . rowDetailView as RowDetailView , 'onRowOutOfViewportRange' ) ;
662
+ const onRowBackViewSpy = jest . spyOn ( gridOptionsMock . rowDetailView as RowDetailView , 'onRowBackToViewportRange' ) ;
663
+
664
+ plugin . init ( gridStub ) ;
665
+ plugin . onBeforeRowDetailToggle = new SlickEvent ( ) ;
666
+ plugin . register ( ) ;
667
+ const result = plugin . onBeforeRowDetailToggle . notify ( { item : columnsMock [ 0 ] , grid : gridStub } , new SlickEventData ( ) , gridStub ) ;
668
+
669
+ expect ( result . getReturnValue ( ) ) . toEqual ( true ) ;
670
+ expect ( onAsyncRespSpy ) . not . toHaveBeenCalled ( ) ;
671
+ expect ( onAsyncEndSpy ) . not . toHaveBeenCalled ( ) ;
672
+ expect ( onAfterRowSpy ) . not . toHaveBeenCalled ( ) ;
673
+ expect ( onRowOutViewSpy ) . not . toHaveBeenCalled ( ) ;
674
+ expect ( onRowBackViewSpy ) . not . toHaveBeenCalled ( ) ;
675
+ } ) ;
659
676
} ) ;
660
677
661
678
describe ( 'possible error thrown' , ( ) => {
0 commit comments