Skip to content

Commit

Permalink
feat(add-consent): check for set-all-checkboxes coverage error
Browse files Browse the repository at this point in the history
  • Loading branch information
UralKrc committed Apr 10, 2024
1 parent c5b80a1 commit 29c7d45
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/consent/set-all-checkboxes.spect.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import { getZaraz } from '../helpers/get-zaraz';
import { setAllCheckboxes } from './set-all-checkboxes';

Check warning on line 2 in src/consent/set-all-checkboxes.spect.ts

View check run for this annotation

Codecov / codecov/patch

src/consent/set-all-checkboxes.spect.ts#L1-L2

Added lines #L1 - L2 were not covered by tests

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');

Check warning on line 4 in src/consent/set-all-checkboxes.spect.ts

View check run for this annotation

Codecov / codecov/patch

src/consent/set-all-checkboxes.spect.ts#L4

Added line #L4 was not covered by tests

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({

Check warning on line 9 in src/consent/set-all-checkboxes.spect.ts

View check run for this annotation

Codecov / codecov/patch

src/consent/set-all-checkboxes.spect.ts#L6-L9

Added lines #L6 - L9 were not covered by tests
consent: {
setAllCheckboxes: setAllCheckboxesMock,
},
};
});

setAllCheckboxes(true);

Check warning on line 15 in src/consent/set-all-checkboxes.spect.ts

View check run for this annotation

Codecov / codecov/patch

src/consent/set-all-checkboxes.spect.ts#L15

Added line #L15 was not covered by tests

Expand Down

0 comments on commit 29c7d45

Please sign in to comment.