diff --git a/src/containers/SelectSessionModal/hooks.test.js b/src/containers/SelectSessionModal/hooks.test.js
index 1cb53e7..136c0cb 100644
--- a/src/containers/SelectSessionModal/hooks.test.js
+++ b/src/containers/SelectSessionModal/hooks.test.js
@@ -4,11 +4,19 @@ import { useIntl } from '@edx/frontend-platform/i18n';
import { MockUseState } from 'testUtils';
import { hooks as appHooks, thunkActions } from 'data/redux';
+import track from 'tracking';
import { LEAVE_OPTION } from './constants';
import messages from './messages';
import * as hooks from './hooks';
+jest.mock('tracking', () => ({
+ entitlements: {
+ newSession: jest.fn(),
+ switchSession: jest.fn(),
+ leaveSession: jest.fn(),
+ },
+}));
jest.mock('data/redux', () => ({
hooks: {
useCardCourseData: jest.fn(),
@@ -57,6 +65,13 @@ const testValue = 'test-value';
const courseId = 'test-course-id';
appHooks.useCardCourseRunData.mockReturnValue({ courseId });
+const newSession = jest.fn();
+const switchSession = jest.fn();
+const leaveSession = jest.fn();
+track.entitlements.newSession.mockReturnValue(newSession);
+track.entitlements.switchSession.mockReturnValue(switchSession);
+track.entitlements.leaveSession.mockReturnValue(leaveSession);
+
describe('SelectSessionModal hooks', () => {
let out;
@@ -116,6 +131,7 @@ describe('SelectSessionModal hooks', () => {
state.mockVal(state.keys.selectedSession, LEAVE_OPTION);
runHook({});
out.handleSubmit();
+ expect(leaveSession).toHaveBeenCalledWith();
expect(dispatch).toHaveBeenCalledWith(
thunkActions.app.leaveEntitlementSession(selectedCardId),
);
@@ -126,6 +142,7 @@ describe('SelectSessionModal hooks', () => {
state.mockVal(state.keys.selectedSession, testValue);
runHook({});
out.handleSubmit();
+ expect(newSession).toHaveBeenCalledWith();
expect(dispatch).toHaveBeenCalledWith(
thunkActions.app.newEntitlementEnrollment(selectedCardId, testValue),
);
@@ -136,6 +153,7 @@ describe('SelectSessionModal hooks', () => {
state.mockVal(state.keys.selectedSession, testValue);
runHook({ enrollment: { isEnrolled: true } });
out.handleSubmit();
+ expect(switchSession).toHaveBeenCalledWith();
expect(dispatch).toHaveBeenCalledWith(
thunkActions.app.switchEntitlementEnrollment(selectedCardId, testValue),
);
diff --git a/src/containers/UnenrollConfirmModal/components/ReasonPane.jsx b/src/containers/UnenrollConfirmModal/components/ReasonPane.jsx
index 843767a..9e7054c 100644
--- a/src/containers/UnenrollConfirmModal/components/ReasonPane.jsx
+++ b/src/containers/UnenrollConfirmModal/components/ReasonPane.jsx
@@ -40,7 +40,7 @@ export const ReasonPane = ({
-
+ Submit reason
+
+
+
+`;
+
+exports[`UnenrollConfirmModal ReasonPane snapshot: no reason provided 1`] = `
+
+
+ What's your main reason for unenrolling?
+
+
+
+ I don't have the academic or language prerequisites
+
+
+ The course material was too hard
+
+
+ This won't help me reach my goals
+
+
+ Something was broken
+
+
+ I don't have the time
+
+
+ I just wanted to browse the material
+
+
+ I don't have enough support
+
+
+ I am not happy with the quality of the content
+
+
+ The course material was too easy
+
+
+
+
+
+
+
+ Skip survey
+
+
Submit reason
diff --git a/src/containers/UnenrollConfirmModal/hooks/reasons.js b/src/containers/UnenrollConfirmModal/hooks/reasons.js
index 725b53f..720b893 100644
--- a/src/containers/UnenrollConfirmModal/hooks/reasons.js
+++ b/src/containers/UnenrollConfirmModal/hooks/reasons.js
@@ -39,6 +39,7 @@ export const useUnenrollReasons = ({
const [isSubmitted, setIsSubmitted] = module.state.isSubmitted(false);
const submittedReason = selectedReason === 'custom' ? customOption : selectedReason;
+ const hasReason = ![null, ''].includes(submittedReason);
const handleTrackReasons = module.useTrackUnenrollReasons({ cardId, submittedReason });
@@ -65,6 +66,7 @@ export const useUnenrollReasons = ({
handleClear,
handleSkip,
handleSubmit,
+ hasReason,
isSkipped,
isSubmitted,
selectOption: useValueCallback(setSelectedReason),
diff --git a/src/containers/UnenrollConfirmModal/hooks/reasons.test.js b/src/containers/UnenrollConfirmModal/hooks/reasons.test.js
index e8d3135..cfed357 100644
--- a/src/containers/UnenrollConfirmModal/hooks/reasons.test.js
+++ b/src/containers/UnenrollConfirmModal/hooks/reasons.test.js
@@ -104,6 +104,30 @@ describe('UnenrollConfirmModal reasons hooks', () => {
expect(dispatch).toHaveBeenCalledWith(thunkActions.app.unenrollFromCourse(cardId));
});
});
+ describe('hasReason', () => {
+ it('returns true if an option is selected other than custom', () => {
+ state.mockVal(state.keys.selectedReason, testValue);
+ out = createUseUnenrollReasons();
+ expect(out.hasReason).toEqual(true);
+ });
+ it('returns true if custom option is selected and provided', () => {
+ state.mockVal(state.keys.selectedReason, 'custom');
+ state.mockVal(state.keys.customOption, testValue2);
+ out = createUseUnenrollReasons();
+ expect(out.hasReason).toEqual(true);
+ });
+ it('returns false if no option is selected', () => {
+ state.mockVal(state.keys.selectedReason, null);
+ out = createUseUnenrollReasons();
+ expect(out.hasReason).toEqual(false);
+ });
+ it('returns false if custom option is selcted but not provided', () => {
+ state.mockVal(state.keys.selectedReason, 'custom');
+ state.mockVal(state.keys.customOption, '');
+ out = createUseUnenrollReasons();
+ expect(out.hasReason).toEqual(false);
+ });
+ });
test('isSkipped returns state value', () => {
state.mockVal(state.keys.isSkipped, testValue);
expect(createUseUnenrollReasons().isSkipped).toEqual(testValue);