Skip to content

Commit 509b26f

Browse files
test: fixing test types and handling incorrect props dont match signature
1 parent 23665e0 commit 509b26f

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/containers/EmailSettingsModal/hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const useEmailData = ({
2020
const { mutate: updateEmailSettings } = useUpdateEmailSettings();
2121
const onToggle = () => setIsOptedOut(!isOptedOut);
2222
const save = () => {
23-
updateEmailSettings(cardId, !isOptedOut);
23+
updateEmailSettings({ courseId: cardId, enable: !isOptedOut });
2424
closeModal();
2525
};
2626

src/containers/EmailSettingsModal/hooks.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ describe('EmailSettingsModal hooks', () => {
6262
describe('save', () => {
6363
it('calls updateEmailSettings', () => {
6464
out.save();
65-
expect(updateEmailSettings).toHaveBeenCalledWith(cardId, !out.isOptedOut);
65+
const expectedArg = { courseId: cardId, enable: !out.isOptedOut };
66+
expect(updateEmailSettings).toHaveBeenCalledWith(expectedArg);
6667
});
6768
it('calls closeModal', () => {
6869
out.save();

src/utils/dataTransformers.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ Object.defineProperty(window, 'location', {
1515
});
1616

1717
// Mock URLSearchParams constructor
18-
global.URLSearchParams = jest.fn().mockImplementation(() => ({
19-
get: mockGet,
20-
}));
18+
Object.defineProperty(globalThis, 'URLSearchParams', {
19+
value: jest.fn().mockImplementation(() => ({
20+
get: mockGet,
21+
})),
22+
writable: true,
23+
});
2124

2225
type VisibleListResult = {
2326
visibleList: Array<{

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "@edx/typescript-config",
33
"compilerOptions": {
4+
"types": ["jest", "@testing-library/jest-dom"],
45
"jsx": "react-jsx",
56
"allowJs": true,
67
"allowSyntheticDefaultImports": true,

0 commit comments

Comments
 (0)