From 268ccb4d6be916959f2eadd87d7c506dff1df472 Mon Sep 17 00:00:00 2001 From: Marcos Callegario Date: Tue, 14 Dec 2021 10:01:15 -0300 Subject: [PATCH] feat(filters): change-filter-element-Container-ajust-test --- .../services/__tests__/filter.service.spec.ts | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/common/src/services/__tests__/filter.service.spec.ts b/packages/common/src/services/__tests__/filter.service.spec.ts index 7aa6b176d..68a630a3c 100644 --- a/packages/common/src/services/__tests__/filter.service.spec.ts +++ b/packages/common/src/services/__tests__/filter.service.spec.ts @@ -1642,6 +1642,20 @@ describe('FilterService', () => { gridStub.onHeaderRowCellRendered.notify(mockArgs2 as any, new Slick.EventData(), gridStub); await service.updateFilters(mockNewFilters); + const columnFilterMetadada = service.drawFilterTemplate('name',`#${DOM_ELEMENT_ID}`); + + const filterElm = document.body.querySelector(`#${DOM_ELEMENT_ID}`); + expect(filterElm).toBeTruthy(); + + expect(columnFilterMetadada.columnDef.id).toBe('name'); + }); + it('should Draw DOM Element Filter on custom HTML element by string id with searchTerms', async () => { + service.init(gridStub); + service.bindLocalOnFilter(gridStub); + gridStub.onHeaderRowCellRendered.notify(mockArgs1 as any, new Slick.EventData(), gridStub); + gridStub.onHeaderRowCellRendered.notify(mockArgs2 as any, new Slick.EventData(), gridStub); + await service.updateFilters(mockNewFilters); + const columnFilterMetadada = service.drawFilterTemplate('firstName',`#${DOM_ELEMENT_ID}`); const filterElm = document.body.querySelector(`#${DOM_ELEMENT_ID}`); @@ -1664,8 +1678,9 @@ describe('FilterService', () => { expect(columnFilterMetadada.columnDef.id).toBe('isActive'); }); + - it('should Draw DOM Element Filter on custom HTML element', async () => { + it('should Draw DOM Element Filter on custom HTML element return null', async () => { service.init(gridStub); service.bindLocalOnFilter(gridStub); gridStub.onHeaderRowCellRendered.notify(mockArgs1 as any, new Slick.EventData(), gridStub); @@ -1674,14 +1689,12 @@ describe('FilterService', () => { const filterContainerElm:HTMLDivElement = document.querySelector(`#${DOM_ELEMENT_ID}`); const columnFilterMetadada1 = service.drawFilterTemplate('selector',filterContainerElm); - const columnFilterMetadada2 = service.drawFilterTemplate('name',`#notExist`); - const columnFilterMetadada3 = service.drawFilterTemplate('name',`#${DOM_ELEMENT_ID}`); - - const filterElm = document.body.querySelector(`#${DOM_ELEMENT_ID}`); - expect(filterElm).toBeTruthy(); + const columnFilterMetadada2 = service.drawFilterTemplate('name',`#not-exists`); + const columnFilterMetadada3 = service.drawFilterTemplate('invalid-column',filterContainerElm); - expect(columnFilterMetadada1).toBe(null); - expect(columnFilterMetadada2).toBe(null); + expect(columnFilterMetadada1).toBeNull(); + expect(columnFilterMetadada2).toBeNull(); + expect(columnFilterMetadada3).toBeNull(); }); });