diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.jsx
index da15c2fbc..cdd8186ac 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.jsx
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.jsx
@@ -1,9 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
+import { connect } from 'react-redux';
import { injectIntl, FormattedMessage, intlShape } from '@edx/frontend-platform/i18n';
import { Form, Hyperlink } from '@edx/paragon';
import SettingsOption from '../SettingsOption';
import { ShowAnswerTypes, ShowAnswerTypesKeys } from '../../../../../../data/constants/problem';
+import { selectors } from '../../../../../../data/redux';
import messages from '../messages';
import { showAnswerCardHooks } from '../hooks';
@@ -12,6 +14,9 @@ export const ShowAnswerCard = ({
updateSettings,
// inject
intl,
+ // redux
+ studioEndpointUrl,
+ learningContextId,
}) => {
const {
handleShowAnswerChange,
@@ -29,7 +34,7 @@ export const ShowAnswerCard = ({
-
+
@@ -49,7 +54,7 @@ export const ShowAnswerCard = ({
))}
- { showAttempts
+ {showAttempts
&& (
({
+ studioEndpointUrl: selectors.app.studioEndpointUrl(state),
+ learningContextId: selectors.app.learningContextId(state),
+});
+
+export const mapDispatchToProps = {};
+
+export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ShowAnswerCard));
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx
index e727746e2..63d2e2bfe 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx
@@ -1,13 +1,23 @@
import React from 'react';
import { shallow } from 'enzyme';
import { formatMessage } from '../../../../../../../testUtils';
-import { ShowAnswerCard } from './ShowAnswerCard';
+import { selectors } from '../../../../../../data/redux';
+import { ShowAnswerCard, mapStateToProps, mapDispatchToProps } from './ShowAnswerCard';
import { showAnswerCardHooks } from '../hooks';
jest.mock('../hooks', () => ({
showAnswerCardHooks: jest.fn(),
}));
+jest.mock('../../../../../../data/redux', () => ({
+ selectors: {
+ app: {
+ studioEndpointUrl: jest.fn(state => ({ studioEndpointUrl: state })),
+ learningContextId: jest.fn(state => ({ learningContextId: state })),
+ },
+ },
+}));
+
describe('ShowAnswerCard', () => {
const showAnswer = {
on: 'after_attempts',
@@ -17,7 +27,11 @@ describe('ShowAnswerCard', () => {
};
const props = {
showAnswer,
+ // injected
intl: { formatMessage },
+ // redux
+ studioEndpointUrl: 'SoMEeNDpOinT',
+ learningContextId: 'sOMEcouRseId',
};
const showAnswerCardHooksProps = {
@@ -39,4 +53,22 @@ describe('ShowAnswerCard', () => {
expect(shallow()).toMatchSnapshot();
});
});
+ describe('mapStateToProps', () => {
+ const testState = { A: 'pple', B: 'anana', C: 'ucumber' };
+ test('studioEndpointUrl from app.studioEndpointUrl', () => {
+ expect(
+ mapStateToProps(testState).studioEndpointUrl,
+ ).toEqual(selectors.app.studioEndpointUrl(testState));
+ });
+ test('learningContextId from app.learningContextId', () => {
+ expect(
+ mapStateToProps(testState).learningContextId,
+ ).toEqual(selectors.app.learningContextId(testState));
+ });
+ });
+ describe('mapDispatchToProps', () => {
+ test('equal an empty object', () => {
+ expect(mapDispatchToProps).toEqual({});
+ });
+ });
});
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap
index 8a750c7b3..7e4b65d7e 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap
@@ -20,7 +20,7 @@ exports[`ShowAnswerCard snapshot snapshot: show answer setting card 1`] = `
className="spacedMessage"
>