Compare commits

...

3 Commits

Author SHA1 Message Date
AhtishamShahid
b0ccfdafb0 test: added unit-test for post editor 2023-02-22 19:21:13 +05:00
AhtishamShahid
b858bc3526 fix: resolved data retention issue in add a post form 2023-02-22 14:35:54 +05:00
AhtishamShahid
3bc6b5d145 fix: resolved data retention issue in add a post form 2023-02-22 14:31:59 +05:00
2 changed files with 11 additions and 1 deletions

View File

@@ -106,7 +106,7 @@ function PostEditor({
const nonCoursewareIds = useSelector(enableInContext ? inContextCoursewareIds : selectNonCoursewareIds);
const coursewareTopics = useSelector(enableInContext ? inContextCourseware : selectCoursewareTopics);
const cohorts = useSelector(selectCourseCohorts);
const post = useSelector(selectThread(postId));
const post = useSelector(editExisting ? selectThread(postId) : () => ({}));
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const settings = useSelector(selectDivisionSettings);

View File

@@ -141,6 +141,16 @@ describe('PostEditor', () => {
}
},
);
test('selectThread is not called while creating a new post', async () => {
const mockSelectThread = jest.fn();
jest.mock('../data/selectors', () => ({
selectThread: mockSelectThread,
}));
await renderComponent();
expect(mockSelectThread)
.not
.toHaveBeenCalled();
});
});
describe('cohorting', () => {