Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit b3bc98e

Browse files
committed
chore: add missing unit test coverage
1 parent 03c2c64 commit b3bc98e

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/app/modules/angular-slickgrid/extensions/__tests__/slickRowDetailView.spec.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const gridOptionsMock = {
4747
useSimpleViewportCalc: true,
4848
saveDetailViewOnScroll: false,
4949
process: () => new Promise((resolve) => resolve('process resolved')),
50-
viewComponent: null,
50+
viewComponent: null as any,
5151
onExtensionRegistered: jest.fn(),
5252
onAsyncResponse: () => { },
5353
onAsyncEndUpdate: () => { },
@@ -309,11 +309,6 @@ describe('SlickRowDetailView', () => {
309309
plugin.register();
310310
plugin.onBeforeRowDetailToggle.notify({ item: columnsMock[0], grid: gridStub }, new SlickEventData(), gridStub);
311311

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-
// );
317312
expect(onAsyncRespSpy).not.toHaveBeenCalled();
318313
expect(onAsyncEndSpy).not.toHaveBeenCalled();
319314
expect(onAfterRowSpy).not.toHaveBeenCalled();
@@ -656,6 +651,28 @@ describe('SlickRowDetailView', () => {
656651
expect(disposeSpy).toHaveBeenCalled();
657652
expect(disposeAllSpy).toHaveBeenCalled();
658653
});
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+
});
659676
});
660677

661678
describe('possible error thrown', () => {

0 commit comments

Comments
 (0)