diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/__snapshots__/index.test.jsx.snap deleted file mode 100644 index f3577747a..000000000 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/__snapshots__/index.test.jsx.snap +++ /dev/null @@ -1,224 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EditorProblemView component renders markdown editor when isMarkdownEditorEnabled is true 1`] = ` - - - - - - } - isOpen={false} - onClose={[Function]} - title="No answer specified" - > - -
- -
-
- -
-
-
-
- - - - - - -
-
-`; - -exports[`EditorProblemView component renders raw editor for advanced problem type 1`] = ` - - - - - - } - isOpen={false} - onClose={[Function]} - title="OLX settings discrepancy" - > - - -
- - - - - - -
-
-`; - -exports[`EditorProblemView component renders simple view 1`] = ` - - - - - - } - isOpen={false} - onClose={[Function]} - title="No answer specified" - > - -
- -
-
- -
-
-
-
- - - - - - - - -
-
-`; diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/index.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/index.jsx index c584aa7b9..61c2b6718 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/index.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/index.jsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react'; import PropTypes from 'prop-types'; import { connect, useDispatch } from 'react-redux'; -import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n'; +import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n'; import { Container, @@ -36,17 +36,15 @@ const EditProblemView = ({ returnUrl, analytics, isDirty, - // injected - intl, }) => { + const intl = useIntl(); const dispatch = useDispatch(); const editorRef = useRef(null); const isAdvancedProblemType = problemType === ProblemTypeKeys.ADVANCED; const { isSaveWarningModalOpen, openSaveWarningModal, closeSaveWarningModal } = saveWarningModalToggle(); - + /* istanbul ignore next */ const checkIfDirty = () => { if (isAdvancedProblemType && editorRef && editorRef?.current) { - /* istanbul ignore next */ return editorRef.current.observer?.lastChange !== 0; } return isDirty || checkIfEditorsDirty(); @@ -145,8 +143,6 @@ EditProblemView.propTypes = { returnUrl: PropTypes.string.isRequired, isDirty: PropTypes.bool, isMarkdownEditorEnabled: PropTypes.bool, - // injected - intl: intlShape.isRequired, }; export const mapStateToProps = (state) => ({ @@ -161,4 +157,4 @@ export const mapStateToProps = (state) => ({ }); export const EditProblemViewInternal = EditProblemView; // For testing only -export default injectIntl(connect(mapStateToProps)(EditProblemView)); +export default connect(mapStateToProps)(EditProblemView); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/index.test.jsx index ca9174c8c..5232c7b31 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/index.test.jsx @@ -1,62 +1,147 @@ -import 'CourseAuthoring/editors/setupEditorTest'; import React from 'react'; -import { shallow } from '@edx/react-unit-test-utils'; -import { EditProblemViewInternal as EditProblemView } from '.'; -import { AnswerWidgetInternal as AnswerWidget } from './AnswerWidget'; +import { Provider } from 'react-redux'; +import { + render as baseRender, screen, fireEvent, initializeMocks, +} from '../../../../../testUtils'; +import { EditProblemViewInternal, mapStateToProps } from './index'; import { ProblemTypeKeys } from '../../../../data/constants/problem'; -import RawEditor from '../../../../sharedComponents/RawEditor'; -import { formatMessage } from '../../../../testUtils'; +import { EditorContextProvider } from '../../../../EditorContext'; +import editorStore from '../../../../data/store'; +import { selectors } from '../../../../data/redux'; -describe('EditorProblemView component', () => { - test('renders simple view', () => { - const wrapper = shallow(); - expect(wrapper.snapshot).toMatchSnapshot(); +const { saveBlock } = require('../../../../hooks'); +const { saveWarningModalToggle } = require('./hooks'); - const AnswerWidgetComponent = wrapper.shallowWrapper.props.children[1].props.children[1].props.children; - expect(AnswerWidgetComponent.props.problemType).toBe(ProblemTypeKeys.SINGLESELECT); - expect(wrapper.instance.findByType(RawEditor).length).toBe(0); +jest.mock('./AnswerWidget', () => function mockAnswerWidget() { + return
AnswerWidget
; +}); +jest.mock('./SettingsWidget', () => function mockSettingsWidget() { + return
SettingsWidget
; +}); +jest.mock('./QuestionWidget', () => function mmockQuestionWidget() { + return
QuestionWidget
; +}); +jest.mock('../../../EditorContainer', () => function mockEditorContainer({ children }) { + return
{children}
; +}); +jest.mock('../../../../sharedComponents/RawEditor', () => function mockRawEditor({ lang, content }) { + return
{lang}:{content}
; +}); +jest.mock('./ExplanationWidget', () => function mockExplanationWidget() { + return
ExplanationWidget
; +}); +jest.mock('../../../../hooks', () => ({ + saveBlock: jest.fn(), +})); +jest.mock('./hooks', () => ({ + checkIfEditorsDirty: jest.fn(() => false), + parseState: jest.fn(() => () => 'parsed-content'), + saveWarningModalToggle: jest.fn(() => ({ + isSaveWarningModalOpen: true, + openSaveWarningModal: jest.fn(), + closeSaveWarningModal: jest.fn(), + })), + getContent: jest.fn(() => 'content'), +})); + +const render = (ui) => baseRender(ui, { + extraWrapper: ({ children }) => ( + + + {children} + + + ), +}); + +describe('EditProblemView', () => { + const baseProps = { + problemType: 'standard', + isMarkdownEditorEnabled: false, + problemState: { rawOLX: '', rawMarkdown: '## Problem' }, + lmsEndpointUrl: null, + returnUrl: '/return', + analytics: {}, + isDirty: false, + returnFunction: jest.fn(), + }; + + beforeEach(() => { + initializeMocks(); }); - test('renders raw editor for advanced problem type', () => { - const wrapper = shallow(...' }} - assets={{}} - intl={{ formatMessage }} - />); - - expect(wrapper.snapshot).toMatchSnapshot(); - - const rawEditor = wrapper.instance.findByType(RawEditor); - expect(rawEditor.length).toBe(1); - expect(rawEditor[0].props.lang).toBe('xml'); - - const answerWidget = wrapper.instance.findByType(AnswerWidget); - expect(answerWidget.length).toBe(0); // since advanced problem type skips AnswerWidget + it('renders standard problem widgets', () => { + render(); + expect(screen.getByText('QuestionWidget')).toBeInTheDocument(); + expect(screen.getByText('ExplanationWidget')).toBeInTheDocument(); + expect(screen.getByText('AnswerWidget')).toBeInTheDocument(); + expect(screen.getByText('SettingsWidget')).toBeInTheDocument(); + expect(screen.queryByText(/xml:/)).not.toBeInTheDocument(); + expect(screen.queryByText(/markdown:/)).not.toBeInTheDocument(); }); - test('renders markdown editor when isMarkdownEditorEnabled is true', () => { - const wrapper = shallow(); + it('renders advanced problem with RawEditor', () => { + render(); + expect(screen.getByText('xml:')).toBeInTheDocument(); + expect(screen.getByText('SettingsWidget')).toBeInTheDocument(); + }); - expect(wrapper.snapshot).toMatchSnapshot(); + it('renders markdown editor with RawEditor', () => { + render(); + expect(screen.getByText('markdown:## Problem')).toBeInTheDocument(); + }); - const rawEditor = wrapper.instance.findByType(RawEditor); - expect(rawEditor.length).toBe(1); - expect(rawEditor[0].props.lang).toBe('markdown'); + it('shows AlertModal with correct title/body for standard', () => { + render(); + expect(screen.getAllByText('No correct answer has been specified.').length).toBeGreaterThan(0); + }); - const answerWidget = wrapper.instance.findByType(AnswerWidget); - expect(answerWidget.length).toBe(0); // since markdown view skips AnswerWidget + it('calls saveBlock when save button is clicked', () => { + render(); + const saveBtn = screen.getByRole('button', { name: 'Ok' }); + fireEvent.click(saveBtn); + expect(saveBlock).toHaveBeenCalled(); + }); + + it('calls closeSaveWarningModal when cancel button is clicked', () => { + const closeSaveWarningModal = jest.fn(); + saveWarningModalToggle.mockReturnValue({ + isSaveWarningModalOpen: true, + openSaveWarningModal: jest.fn(), + closeSaveWarningModal, + }); + render(); + const cancelBtn = screen.getByRole('button', { name: 'Cancel' }); + fireEvent.click(cancelBtn); + expect(closeSaveWarningModal).toHaveBeenCalled(); + }); + + it('sets isMarkdownEditorEnabled true only if both selectors return true', () => { + const state = { }; + + selectors.problem = { + isMarkdownEditorEnabled: jest.fn(() => true), + problemType: jest.fn(), + completeState: jest.fn(), + isDirty: jest.fn(), + }; + selectors.app = { + isMarkdownEditorEnabledForCourse: jest.fn(() => true), + analytics: jest.fn(), + lmsEndpointUrl: jest.fn(), + returnUrl: jest.fn(), + }; + + const props = mapStateToProps(state); + expect(selectors.problem.isMarkdownEditorEnabled).toHaveBeenCalledWith(state); + expect(selectors.app.isMarkdownEditorEnabledForCourse).toHaveBeenCalledWith(state); + expect(props.isMarkdownEditorEnabled).toBe(true); + + selectors.problem.isMarkdownEditorEnabled.mockReturnValue(false); + expect(mapStateToProps(state).isMarkdownEditorEnabled).toBe(false); + + selectors.problem.isMarkdownEditorEnabled.mockReturnValue(true); + selectors.app.isMarkdownEditorEnabledForCourse.mockReturnValue(false); + expect(mapStateToProps(state).isMarkdownEditorEnabled).toBe(false); }); }); diff --git a/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/ProblemTypeSelect.test.tsx b/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/ProblemTypeSelect.test.tsx index e7d433c92..742c80baf 100644 --- a/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/ProblemTypeSelect.test.tsx +++ b/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/ProblemTypeSelect.test.tsx @@ -1,39 +1,42 @@ -import 'CourseAuthoring/editors/setupEditorTest'; - -import { shallow } from '@edx/react-unit-test-utils'; +import React from 'react'; +import { + render, screen, fireEvent, initializeMocks, +} from '../../../../../../testUtils'; import { ProblemTypeKeys } from '../../../../../data/constants/problem'; import ProblemTypeSelect from './ProblemTypeSelect'; describe('ProblemTypeSelect', () => { - const props = { - setSelected: jest.fn(), - }; + beforeEach(() => { + initializeMocks(); + }); - describe('snapshot', () => { - test('SINGLESELECT', () => { - expect(shallow( - , - ).snapshot).toMatchSnapshot(); - }); - test('MULTISELECT', () => { - expect(shallow( - , - ).snapshot).toMatchSnapshot(); - }); - test('DROPDOWN', () => { - expect(shallow( - , - ).snapshot).toMatchSnapshot(); - }); - test('NUMERIC', () => { - expect(shallow( - , - ).snapshot).toMatchSnapshot(); - }); - test('TEXTINPUT', () => { - expect(shallow( - , - ).snapshot).toMatchSnapshot(); - }); + it('renders the component with the selected element checked', () => { + render(); + expect(screen.getByRole('radiogroup')).toBeInTheDocument(); + const radioSingle = screen.getByDisplayValue('multiplechoiceresponse'); + expect(radioSingle).toBeChecked(); + }); + + it('does not render advanced element', () => { + render(); + expect(screen.getByRole('radiogroup')).toBeInTheDocument(); + expect(screen.queryByText('advanced')).not.toBeInTheDocument(); + }); + + it('should call setSelected with correct value when clicking one option', () => { + const mockSetSelected = jest.fn(); + render(); + const multiSelectOption = screen.getByRole('button', { name: 'Multi-select' }); + fireEvent.click(multiSelectOption); + expect(mockSetSelected).toHaveBeenCalledWith('choiceresponse'); + }); + + it('should call setSelected with blankadvanced when clicking the advanced button', () => { + const mockSetSelected = jest.fn(); + render(); + const button = screen.getByRole('button', { name: 'Advanced problem types' }); + expect(button).toBeInTheDocument(); + fireEvent.click(button); + expect(mockSetSelected).toHaveBeenCalledWith('blankadvanced'); }); }); diff --git a/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/__snapshots__/ProblemTypeSelect.test.tsx.snap b/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/__snapshots__/ProblemTypeSelect.test.tsx.snap deleted file mode 100644 index f21b39268..000000000 --- a/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/__snapshots__/ProblemTypeSelect.test.tsx.snap +++ /dev/null @@ -1,531 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ProblemTypeSelect snapshot DROPDOWN 1`] = ` - - - - Single select - - - Multi-select - - - Dropdown - - - Numerical input - - - Text input - - - - -`; - -exports[`ProblemTypeSelect snapshot MULTISELECT 1`] = ` - - - - Single select - - - Multi-select - - - Dropdown - - - Numerical input - - - Text input - - - - -`; - -exports[`ProblemTypeSelect snapshot NUMERIC 1`] = ` - - - - Single select - - - Multi-select - - - Dropdown - - - Numerical input - - - Text input - - - - -`; - -exports[`ProblemTypeSelect snapshot SINGLESELECT 1`] = ` - - - - Single select - - - Multi-select - - - Dropdown - - - Numerical input - - - Text input - - - - -`; - -exports[`ProblemTypeSelect snapshot TEXTINPUT 1`] = ` - - - - Single select - - - Multi-select - - - Dropdown - - - Numerical input - - - Text input - - - - -`; diff --git a/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.jsx b/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.jsx deleted file mode 100644 index a8b1f0504..000000000 --- a/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.jsx +++ /dev/null @@ -1,84 +0,0 @@ -import 'CourseAuthoring/editors/setupEditorTest'; -import React from 'react'; -import { shallow } from '@edx/react-unit-test-utils'; -import ErrorAlert, { hooks } from './ErrorAlert'; -import { MockUseState } from '../../testUtils'; - -jest.mock('react', () => ({ - ...jest.requireActual('react'), - useRef: jest.fn(val => ({ current: val })), - useEffect: jest.fn(), - useCallback: (cb, prereqs) => ({ cb, prereqs }), -})); - -const state = new MockUseState(hooks); -let hook; -const testValue = 'testVALUE'; - -describe('ErrorAlert component', () => { - describe('Hooks', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - describe('state hooks', () => { - state.testGetter(state.keys.isDismissed); - }); - describe('using state', () => { - beforeEach(() => { state.mock(); }); - afterEach(() => { state.restore(); }); - describe('dismissalHooks', () => { - const props = { - dismissError: jest.fn(), - isError: testValue, - }; - beforeEach(() => { - hook = hooks.dismissalHooks(props); - }); - it('returns isDismissed value, initialized to false', () => { - expect(state.stateVals.isDismissed).toEqual(hook.isDismissed); - }); - test('dismissAlert sets isDismissed to true and calls dismissError', () => { - hook.dismissAlert(); - expect(state.setState.isDismissed).toHaveBeenCalledWith(true); - expect(props.dismissError).toHaveBeenCalled(); - }); - test('On Render, calls setIsDismissed', () => { - expect(React.useEffect.mock.calls.length).toEqual(1); - const [cb, prereqs] = React.useEffect.mock.calls[0]; - expect(prereqs[0]).toEqual(testValue); - cb(); - expect(state.setState.isDismissed).toHaveBeenCalledWith(state.stateVals.isDismissed && !testValue); - }); - }); - }); - }); - describe('Component', () => { - describe('Snapshots', () => { - let props; - const msg =

An Error Message

; - beforeAll(() => { - props = { - dismissError: jest.fn(), - }; - jest.spyOn(hooks, 'dismissalHooks').mockImplementation(() => ({ - isDismissed: false, - dismissAlert: jest.fn().mockName('dismissAlert'), - })); - }); - afterAll(() => { - jest.clearAllMocks(); - }); - test('snapshot: is Null when no error (ErrorAlert)', () => { - expect(shallow(

An Error Message

).snapshot).toMatchSnapshot(); - }); - test('snapshot: Loads children and component when error (ErrorAlert)', () => { - expect( - shallow({msg}).snapshot, - ).toMatchSnapshot(); - }); - test('snapshot: Does not load heading when hideHeading is true', () => { - expect(shallow({msg}).snapshot).toMatchSnapshot(); - }); - }); - }); -}); diff --git a/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.tsx b/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.tsx new file mode 100644 index 000000000..4ef684acd --- /dev/null +++ b/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.tsx @@ -0,0 +1,84 @@ +import React from 'react'; +import { + render, screen, fireEvent, initializeMocks, +} from '../../../testUtils'; +import ErrorAlert, { hooks } from './ErrorAlert'; + +describe('ErrorAlert (integration, no Paragon mocks)', () => { + beforeEach(() => { + initializeMocks(); + }); + + afterEach(() => { + jest.restoreAllMocks(); + }); + + it('renders nothing if isError is false', () => { + render(Some error); + expect(screen.queryByRole('alert')).toBeNull(); + }); + + it('renders nothing if isDismissed is true', () => { + jest.spyOn(hooks, 'dismissalHooks').mockReturnValue({ + isDismissed: true, + dismissAlert: jest.fn(), + }); + render(Some error); + expect(screen.queryByRole('alert')).toBeNull(); + }); + + it('renders alert with heading and children when isError is true', () => { + jest.spyOn(hooks, 'dismissalHooks').mockReturnValue({ + isDismissed: false, + dismissAlert: jest.fn(), + }); + render(Some error); + expect(screen.getByRole('alert')).toBeInTheDocument(); + expect(screen.getByText('Error')).toBeInTheDocument(); + expect(screen.getByText('Some error')).toBeInTheDocument(); + }); + + it('renders alert without heading when hideHeading is true', () => { + render(Some error); + expect(screen.getByRole('alert')).toBeInTheDocument(); + expect(screen.queryByText('Error')).toBeNull(); + expect(screen.getByText('Some error')).toBeInTheDocument(); + }); + + it('calls dismissError when dismiss button is clicked', () => { + const dismissError = jest.fn(); + render(Some error); + const closeBtn = screen.getByRole('button'); + fireEvent.click(closeBtn); + expect(dismissError).toHaveBeenCalled(); + }); + + it('does not throw if dismissError is not provided and dismiss button is clicked', () => { + render(Some error); + const closeBtn = screen.getByRole('button'); + expect(() => fireEvent.click(closeBtn)).not.toThrow(); + }); + + it('renders children as array', () => { + render({['foo', bar]}); + expect(screen.getByText('foo')).toBeInTheDocument(); + expect(screen.getByText('bar')).toBeInTheDocument(); + }); + + it('resets isDismissed when isError changes from false to true', () => { + const { rerender } = render(err); + expect(screen.queryByRole('alert')).toBeNull(); + rerender(err); + expect(screen.getByRole('alert')).toBeInTheDocument(); + }); + + it('dismisses alert when dismiss button is clicked (integration)', () => { + const dismissError = jest.fn(); + render(err); + const closeBtn = screen.getByRole('button'); + fireEvent.click(closeBtn); + + expect(screen.queryByRole('alert')).toBeNull(); + expect(dismissError).toHaveBeenCalled(); + }); +}); diff --git a/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.jsx b/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.jsx deleted file mode 100644 index 2a849ba41..000000000 --- a/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import 'CourseAuthoring/editors/setupEditorTest'; -import React from 'react'; -import { shallow } from '@edx/react-unit-test-utils'; -import FetchErrorAlert from './FetchErrorAlert'; - -jest.mock('../../data/redux', () => ({ - selectors: { - requests: { - isFailed: jest.fn((state, params) => ({ isFailed: { state, params } })), - }, - }, -})); - -describe('FetchErrorAlert', () => { - describe('Snapshots', () => { - test('snapshot: is ErrorAlert with Message error (ErrorAlert)', () => { - expect(shallow().snapshot).toMatchSnapshot(); - }); - }); -}); diff --git a/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.tsx b/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.tsx new file mode 100644 index 000000000..87c0218a0 --- /dev/null +++ b/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { render, screen, initializeMocks } from '../../../testUtils'; +import FetchErrorAlert from './FetchErrorAlert'; + +const message = { + id: 'test.error', + defaultMessage: 'Something went wrong!', + description: 'Test error message', +}; + +describe('FetchErrorAlert', () => { + beforeEach(() => { + initializeMocks(); + }); + + it('renders the error message when isFetchError is true', () => { + render( + , + ); + expect(screen.getByText('Something went wrong!')).toBeInTheDocument(); + }); + + it('does not render the error message when isFetchError is false', () => { + render( + , + ); + expect(screen.queryByText('Something went wrong!')).not.toBeInTheDocument(); + }); + + it('renders error with a custom message', () => { + const customMessage = { + id: 'another.error', + defaultMessage: 'Another error occurred.', + description: 'Another error', + }; + render( + , + ); + expect(screen.getByText('Another error occurred.')).toBeInTheDocument(); + }); +}); diff --git a/src/editors/sharedComponents/ErrorAlerts/__snapshots__/ErrorAlert.test.jsx.snap b/src/editors/sharedComponents/ErrorAlerts/__snapshots__/ErrorAlert.test.jsx.snap deleted file mode 100644 index 2b2953062..000000000 --- a/src/editors/sharedComponents/ErrorAlerts/__snapshots__/ErrorAlert.test.jsx.snap +++ /dev/null @@ -1,34 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ErrorAlert component Component Snapshots snapshot: Does not load heading when hideHeading is true 1`] = ` - -

- An Error Message -

-
-`; - -exports[`ErrorAlert component Component Snapshots snapshot: Loads children and component when error (ErrorAlert) 1`] = ` - - - - -

- An Error Message -

-
-`; - -exports[`ErrorAlert component Component Snapshots snapshot: is Null when no error (ErrorAlert) 1`] = `null`; diff --git a/src/editors/sharedComponents/ErrorAlerts/__snapshots__/FetchErrorAlert.test.jsx.snap b/src/editors/sharedComponents/ErrorAlerts/__snapshots__/FetchErrorAlert.test.jsx.snap deleted file mode 100644 index bc4615752..000000000 --- a/src/editors/sharedComponents/ErrorAlerts/__snapshots__/FetchErrorAlert.test.jsx.snap +++ /dev/null @@ -1,11 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`FetchErrorAlert Snapshots snapshot: is ErrorAlert with Message error (ErrorAlert) 1`] = ` - - - -`; diff --git a/src/selectors/VideoSelectorContainer.test.jsx b/src/selectors/VideoSelectorContainer.test.jsx deleted file mode 100644 index f32053f40..000000000 --- a/src/selectors/VideoSelectorContainer.test.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; -import { shallow } from '@edx/react-unit-test-utils'; -import VideoSelectorContainer from './VideoSelectorContainer'; - -jest.mock('../editors/VideoSelectorPage', () => ({ - default: function VideoSelectorPage() { return 'HeaderTitle'; }, - __esModule: true, // Required to mock a default export -})); - -jest.mock('react-router', () => ({ - ...jest.requireActual('react-router'), // use actual for all non-hook parts - useParams: () => ({ - blockId: 'company-id1', - blockType: 'html', - }), -})); - -const props = { courseId: 'cOuRsEId' }; - -describe('Video Selector Container', () => { - describe('snapshots', () => { - test('rendering correctly with expected Input', () => { - expect(shallow().snapshot).toMatchSnapshot(); - }); - }); -}); diff --git a/src/selectors/VideoSelectorContainer.test.tsx b/src/selectors/VideoSelectorContainer.test.tsx new file mode 100644 index 000000000..007d59040 --- /dev/null +++ b/src/selectors/VideoSelectorContainer.test.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { render, initializeMocks } from '../testUtils'; +import VideoSelectorContainer from './VideoSelectorContainer'; + +describe('VideoSelectorContainer', () => { + beforeEach(() => { + initializeMocks(); + }); + + it('renders the wrapper div with correct class', () => { + const { container } = render(); + expect(container.querySelector('.selector-page')).toBeInTheDocument(); + }); +}); diff --git a/src/selectors/__snapshots__/VideoSelectorContainer.test.jsx.snap b/src/selectors/__snapshots__/VideoSelectorContainer.test.jsx.snap deleted file mode 100644 index a05e8349d..000000000 --- a/src/selectors/__snapshots__/VideoSelectorContainer.test.jsx.snap +++ /dev/null @@ -1,14 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Video Selector Container snapshots rendering correctly with expected Input 1`] = ` -
- -
-`;