From 29c7d455ed8bc5578fa2d168ad6ba8a3c961d07c Mon Sep 17 00:00:00 2001 From: Ural Date: Wed, 10 Apr 2024 16:23:10 +0200 Subject: [PATCH] feat(add-consent): check for set-all-checkboxes coverage error --- src/consent/set-all-checkboxes.spect.ts | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/consent/set-all-checkboxes.spect.ts b/src/consent/set-all-checkboxes.spect.ts index 29c3acc..9000850 100644 --- a/src/consent/set-all-checkboxes.spect.ts +++ b/src/consent/set-all-checkboxes.spect.ts @@ -1,30 +1,16 @@ +import { getZaraz } from '../helpers/get-zaraz'; import { setAllCheckboxes } from './set-all-checkboxes'; -declare global { - interface Window { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - zaraz: any; - } -} - -let windowObj: Window & typeof globalThis; - -beforeAll(() => { - windowObj = window; -}); - -afterAll(() => { - window = windowObj; -}); +jest.mock('../helpers/get-zaraz'); describe('setAllCheckboxes()', () => { it('should call setAllCheckboxes method on zaraz consent with the correct argument', () => { const setAllCheckboxesMock = jest.fn(); - window.zaraz = { + (getZaraz as jest.Mock).mockReturnValue({ consent: { setAllCheckboxes: setAllCheckboxesMock, }, - }; + }); setAllCheckboxes(true);