diff --git a/src/containers/ResponseDisplay/components/FilePopoverCell.test.jsx b/src/containers/ResponseDisplay/components/FilePopoverCell.test.jsx
index 46fdd6f..5c8f2a4 100644
--- a/src/containers/ResponseDisplay/components/FilePopoverCell.test.jsx
+++ b/src/containers/ResponseDisplay/components/FilePopoverCell.test.jsx
@@ -1,37 +1,59 @@
-import React from 'react';
-import { shallow } from '@edx/react-unit-test-utils';
+import { render } from '@testing-library/react';
+import { IntlProvider } from '@edx/frontend-platform/i18n';
-import FilePopoverContent from 'components/FilePopoverContent';
import FilePopoverCell from './FilePopoverCell';
-jest.mock('components/InfoPopover', () => 'InfoPopover');
-jest.mock('components/FilePopoverContent', () => 'FilePopoverContent');
+const mockMessages = {
+ en: {},
+};
+
+const renderWithIntl = (component) => render(
+
+ {component}
+ ,
+);
describe('FilePopoverCell', () => {
- describe('component', () => {
- const props = {
+ const props = {
+ row: {
+ original: {
+ name: 'some file name',
+ description: 'long descriptive text...',
+ downloadURL: 'this-url-is.working',
+ size: 1024,
+ },
+ },
+ };
+
+ it('renders the component without errors', () => {
+ const { container } = renderWithIntl();
+ expect(container.firstChild).toBeInTheDocument();
+ });
+
+ it('renders the info icon button', () => {
+ const { getByTestId } = renderWithIntl();
+ expect(getByTestId('esg-help-icon')).toBeInTheDocument();
+ });
+
+ it('info button has correct alt text', () => {
+ const { getByTestId } = renderWithIntl();
+ const button = getByTestId('esg-help-icon');
+ expect(button).toHaveAttribute('alt', 'Display more info');
+ });
+
+ it('handles empty row.original object', () => {
+ const emptyProps = {
row: {
- original: {
- name: 'some file name',
- description: 'long descriptive text...',
- downloadURL: 'this-url-is.working',
- },
+ original: {},
},
};
- let el;
- beforeEach(() => {
- el = shallow();
- });
- test('snapshot', () => {
- expect(el.snapshot).toMatchSnapshot();
- });
- describe('behavior', () => {
- test('content', () => {
- const { original } = props.row;
- const content = el.instance.findByType(FilePopoverContent)[0];
- expect(content.props).toEqual({ ...original });
- });
- });
+ const { container } = renderWithIntl();
+ expect(container.firstChild).toBeInTheDocument();
+ });
+
+ it('handles missing row prop', () => {
+ const { container } = renderWithIntl();
+ expect(container.firstChild).toBeInTheDocument();
});
});
diff --git a/src/containers/ResponseDisplay/components/__snapshots__/FilePopoverCell.test.jsx.snap b/src/containers/ResponseDisplay/components/__snapshots__/FilePopoverCell.test.jsx.snap
deleted file mode 100644
index 3964b21..0000000
--- a/src/containers/ResponseDisplay/components/__snapshots__/FilePopoverCell.test.jsx.snap
+++ /dev/null
@@ -1,11 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`FilePopoverCell component snapshot 1`] = `
-
-
-
-`;
diff --git a/src/containers/ReviewActions/__snapshots__/index.test.jsx.snap b/src/containers/ReviewActions/__snapshots__/index.test.jsx.snap
deleted file mode 100644
index 3b1da0a..0000000
--- a/src/containers/ReviewActions/__snapshots__/index.test.jsx.snap
+++ /dev/null
@@ -1,141 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`ReviewActions component component snapshot: do not show rubric 1`] = `
-
-
-
-
- test-userDisplay
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`ReviewActions component component snapshot: loading 1`] = `
-
-
-
-
- test-userDisplay
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`ReviewActions component component snapshot: show rubric, no score 1`] = `
-
-
-
-
- test-userDisplay
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/src/containers/ReviewActions/components/OverrideGradeConfirmModal.test.jsx b/src/containers/ReviewActions/components/OverrideGradeConfirmModal.test.jsx
index 7f48882..6bc037a 100644
--- a/src/containers/ReviewActions/components/OverrideGradeConfirmModal.test.jsx
+++ b/src/containers/ReviewActions/components/OverrideGradeConfirmModal.test.jsx
@@ -1,8 +1,16 @@
-import { shallow } from '@edx/react-unit-test-utils';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { IntlProvider } from '@edx/frontend-platform/i18n';
+import OverrideGradeConfirmModal from './OverrideGradeConfirmModal';
-import { OverrideGradeConfirmModal } from './OverrideGradeConfirmModal';
+jest.unmock('@openedx/paragon');
+jest.unmock('react');
-jest.mock('components/ConfirmModal', () => 'ConfirmModal');
+const renderWithIntl = (component) => render(
+
+ {component}
+ ,
+);
describe('OverrideGradeConfirmModal', () => {
const props = {
@@ -10,10 +18,33 @@ describe('OverrideGradeConfirmModal', () => {
onCancel: jest.fn().mockName('this.props.onCancel'),
onConfirm: jest.fn().mockName('this.props.onConfirm'),
};
- test('snapshot: closed', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ beforeEach(() => {
+ jest.clearAllMocks();
});
- test('snapshot: open', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ it('should not render content when modal is closed', () => {
+ const { queryByText } = renderWithIntl();
+ expect(queryByText('This cannot be undone')).toBeNull();
+ });
+
+ it('should display content when modal is open', () => {
+ const { getByText } = renderWithIntl();
+ expect(getByText('Are you sure you want to override this grade?')).toBeInTheDocument();
+ expect(getByText(/This cannot be undone.*The learner may have already received their grade/)).toBeInTheDocument();
+ });
+
+ it('should call onCancel when cancel button is clicked', async () => {
+ renderWithIntl();
+ const user = userEvent.setup();
+ await user.click(screen.getByText('Go back'));
+ expect(props.onCancel).toHaveBeenCalledTimes(1);
+ });
+
+ it('should call onConfirm when confirm button is clicked', async () => {
+ renderWithIntl();
+ const user = userEvent.setup();
+ await user.click(screen.getByText('Continue grade override'));
+ expect(props.onConfirm).toHaveBeenCalledTimes(1);
});
});
diff --git a/src/containers/ReviewActions/components/StopGradingConfirmModal.test.jsx b/src/containers/ReviewActions/components/StopGradingConfirmModal.test.jsx
index 776dd87..433bd9b 100644
--- a/src/containers/ReviewActions/components/StopGradingConfirmModal.test.jsx
+++ b/src/containers/ReviewActions/components/StopGradingConfirmModal.test.jsx
@@ -1,8 +1,16 @@
-import { shallow } from '@edx/react-unit-test-utils';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { IntlProvider } from '@edx/frontend-platform/i18n';
+import StopGradingConfirmModal from './StopGradingConfirmModal';
-import { StopGradingConfirmModal } from './StopGradingConfirmModal';
+jest.unmock('@openedx/paragon');
+jest.unmock('react');
-jest.mock('components/ConfirmModal', () => 'ConfirmModal');
+const renderWithIntl = (component) => render(
+
+ {component}
+ ,
+);
describe('StopGradingConfirmModal', () => {
const props = {
@@ -11,13 +19,46 @@ describe('StopGradingConfirmModal', () => {
onCancel: jest.fn().mockName('this.props.onCancel'),
onConfirm: jest.fn().mockName('this.props.onConfirm'),
};
- test('snapshot: closed', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ beforeEach(() => {
+ jest.clearAllMocks();
});
- test('snapshot: open', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ it('should not render content when modal is closed', () => {
+ const { queryByText } = renderWithIntl();
+ expect(queryByText('Your progress will be lost.')).toBeNull();
});
- test('snapshot: open, isOverride', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ it('should display stop grading content when modal is open', () => {
+ const { getByText } = renderWithIntl();
+ expect(getByText('Are you sure you want to stop grading this response?')).toBeInTheDocument();
+ expect(getByText('Your progress will be lost.')).toBeInTheDocument();
+ });
+
+ it('should display stop override content when modal is open and isOverride is true', () => {
+ const { getByText } = renderWithIntl();
+ expect(getByText('Are you sure you want to stop grade override?')).toBeInTheDocument();
+ expect(getByText('Your progress will be lost.')).toBeInTheDocument();
+ });
+
+ it('should call onCancel when cancel button is clicked', async () => {
+ renderWithIntl();
+ const user = userEvent.setup();
+ await user.click(screen.getByText('Go back'));
+ expect(props.onCancel).toHaveBeenCalledTimes(1);
+ });
+
+ it('should call onConfirm when confirm button is clicked for regular grading', async () => {
+ renderWithIntl();
+ const user = userEvent.setup();
+ await user.click(screen.getByText('Cancel grading'));
+ expect(props.onConfirm).toHaveBeenCalledTimes(1);
+ });
+
+ it('should call onConfirm when confirm button is clicked for override', async () => {
+ renderWithIntl();
+ const user = userEvent.setup();
+ await user.click(screen.getByText('Stop grade override'));
+ expect(props.onConfirm).toHaveBeenCalledTimes(1);
});
});
diff --git a/src/containers/ReviewActions/components/SubmissionNavigation.test.jsx b/src/containers/ReviewActions/components/SubmissionNavigation.test.jsx
index 50894d2..f590597 100644
--- a/src/containers/ReviewActions/components/SubmissionNavigation.test.jsx
+++ b/src/containers/ReviewActions/components/SubmissionNavigation.test.jsx
@@ -1,73 +1,108 @@
import React from 'react';
-import { shallow } from '@edx/react-unit-test-utils';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { IntlProvider } from '@edx/frontend-platform/i18n';
-import { selectors, thunkActions } from 'data/redux';
+import { thunkActions } from 'data/redux';
import {
SubmissionNavigation,
- mapStateToProps,
mapDispatchToProps,
} from './SubmissionNavigation';
-jest.mock('data/redux/grading/selectors', () => ({
- prev: {
- doesExist: (state) => ({ prevDoesExist: state }),
- },
- next: {
- doesExist: (state) => ({ nextDoesExist: state }),
- },
- activeIndex: (state) => ({ activeIndex: state }),
- selectionLength: (state) => ({ selectionLength: state }),
-}));
-jest.mock('data/redux/requests/selectors', () => ({
- allowNavigation: (state) => ({ allowNavigation: state }),
-}));
+jest.unmock('@openedx/paragon');
+jest.unmock('react');
+
+const mockMessages = {
+ 'ora-grading.ReviewActions.loadPrevious': 'Load previous submission',
+ 'ora-grading.ReviewActions.loadNext': 'Load next submission',
+ 'ora-grading.ReviewActions.navigationLabel': '{current} of {total}',
+};
+
+const renderWithIntl = (component) => render(
+
+ {component}
+ ,
+);
describe('SubmissionNavigation component', () => {
describe('component', () => {
- const props = {
+ const defaultProps = {
activeIndex: 4,
selectionLength: 5,
+ loadNext: jest.fn(),
+ loadPrev: jest.fn(),
+ hasPrevSubmission: true,
+ hasNextSubmission: true,
+ allowNavigation: true,
};
+
beforeEach(() => {
- props.loadNext = jest.fn().mockName('this.props.loadNext');
- props.loadPrev = jest.fn().mockName('this.props.loadPrev');
+ defaultProps.loadNext.mockClear();
+ defaultProps.loadPrev.mockClear();
});
- test('snapshot: no prev submission (disabled)', () => {
- expect(shallow(
- ,
- ).snapshot).toMatchSnapshot();
+
+ it('renders navigation with current position and total submissions', () => {
+ renderWithIntl();
+ expect(screen.getByText('FormattedMessage')).toBeInTheDocument();
});
- test('snapshot: no next submission (disabled)', () => {
- expect(shallow(
- ,
- ).snapshot).toMatchSnapshot();
- });
- });
- describe('mapStateToProps', () => {
- let mapped;
- const testState = { some: 'test-state' };
- beforeEach(() => {
- mapped = mapStateToProps(testState);
- });
- test('activeIndex loads from grading.activeIndex', () => {
- expect(mapped.activeIndex).toEqual(selectors.grading.activeIndex(testState));
- });
- test('hasNextSubmission loads from grading.next.doesExist', () => {
- expect(mapped.hasNextSubmission).toEqual(selectors.grading.next.doesExist(testState));
- });
- test('hasPrevSubmission loads from grading.prev.doesExist', () => {
- expect(mapped.hasPrevSubmission).toEqual(selectors.grading.prev.doesExist(testState));
- });
- test('selectionLength loads from grading.selectionLength', () => {
- expect(mapped.selectionLength).toEqual(selectors.grading.selectionLength(testState));
+
+ it('disables previous button when no previous submission exists', () => {
+ renderWithIntl(
+ ,
+ );
+ const prevButton = screen.getByRole('button', { name: /load previous submission/i });
+ expect(prevButton).toBeDisabled();
+ });
+
+ it('disables next button when no next submission exists', () => {
+ renderWithIntl(
+ ,
+ );
+ const nextButton = screen.getByRole('button', { name: /load next submission/i });
+ expect(nextButton).toBeDisabled();
+ });
+
+ it('disables both buttons when navigation is not allowed', () => {
+ renderWithIntl(
+ ,
+ );
+ const prevButton = screen.getByRole('button', { name: /load previous submission/i });
+ const nextButton = screen.getByRole('button', { name: /load next submission/i });
+ expect(prevButton).toBeDisabled();
+ expect(nextButton).toBeDisabled();
+ });
+
+ it('calls loadPrev when previous button is clicked', async () => {
+ renderWithIntl();
+ const prevButton = screen.getByRole('button', { name: /load previous submission/i });
+ const user = userEvent.setup();
+ await user.click(prevButton);
+ expect(defaultProps.loadPrev).toHaveBeenCalledTimes(1);
+ });
+
+ it('calls loadNext when next button is clicked', async () => {
+ renderWithIntl();
+ const nextButton = screen.getByRole('button', { name: /load next submission/i });
+ const user = userEvent.setup();
+ await user.click(nextButton);
+ expect(defaultProps.loadNext).toHaveBeenCalledTimes(1);
+ });
+
+ it('shows correct position when at first submission', () => {
+ render(
+ ,
+ );
+ expect(screen.getByText('FormattedMessage')).toBeInTheDocument();
});
});
+
describe('mapDispatchToProps', () => {
- it('loads loadNext from thunkActions.grading.loadNext', () => {
+ it('loads loadNext from thunk actions', () => {
expect(mapDispatchToProps.loadNext).toEqual(thunkActions.grading.loadNext);
});
- it('loads loadPrev from thunkActions.grading.loadPrev', () => {
+
+ it('loads loadPrev from thunk actions', () => {
expect(mapDispatchToProps.loadPrev).toEqual(thunkActions.grading.loadPrev);
});
});
diff --git a/src/containers/ReviewActions/components/__snapshots__/OverrideGradeConfirmModal.test.jsx.snap b/src/containers/ReviewActions/components/__snapshots__/OverrideGradeConfirmModal.test.jsx.snap
deleted file mode 100644
index 5cc823a..0000000
--- a/src/containers/ReviewActions/components/__snapshots__/OverrideGradeConfirmModal.test.jsx.snap
+++ /dev/null
@@ -1,25 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`OverrideGradeConfirmModal snapshot: closed 1`] = `
-
-`;
-
-exports[`OverrideGradeConfirmModal snapshot: open 1`] = `
-
-`;
diff --git a/src/containers/ReviewActions/components/__snapshots__/StopGradingConfirmModal.test.jsx.snap b/src/containers/ReviewActions/components/__snapshots__/StopGradingConfirmModal.test.jsx.snap
deleted file mode 100644
index 4ff94bf..0000000
--- a/src/containers/ReviewActions/components/__snapshots__/StopGradingConfirmModal.test.jsx.snap
+++ /dev/null
@@ -1,37 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`StopGradingConfirmModal snapshot: closed 1`] = `
-
-`;
-
-exports[`StopGradingConfirmModal snapshot: open 1`] = `
-
-`;
-
-exports[`StopGradingConfirmModal snapshot: open, isOverride 1`] = `
-
-`;
diff --git a/src/containers/ReviewActions/components/__snapshots__/SubmissionNavigation.test.jsx.snap b/src/containers/ReviewActions/components/__snapshots__/SubmissionNavigation.test.jsx.snap
deleted file mode 100644
index f9cfc5c..0000000
--- a/src/containers/ReviewActions/components/__snapshots__/SubmissionNavigation.test.jsx.snap
+++ /dev/null
@@ -1,81 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`SubmissionNavigation component component snapshot: no next submission (disabled) 1`] = `
-
-
-
-
-
-
-
-`;
-
-exports[`SubmissionNavigation component component snapshot: no prev submission (disabled) 1`] = `
-
-
-
-
-
-
-
-`;
diff --git a/src/containers/ReviewActions/index.test.jsx b/src/containers/ReviewActions/index.test.jsx
index c5dc54a..a33cc38 100644
--- a/src/containers/ReviewActions/index.test.jsx
+++ b/src/containers/ReviewActions/index.test.jsx
@@ -1,74 +1,174 @@
-import React from 'react';
-import { shallow } from '@edx/react-unit-test-utils';
-
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { IntlProvider } from '@edx/frontend-platform/i18n';
import { actions, selectors } from 'data/redux';
import { RequestKeys } from 'data/constants/requests';
-
import { ReviewActions, mapStateToProps, mapDispatchToProps } from '.';
-jest.mock('data/redux/app/selectors', () => ({
- showRubric: (state) => ({ showRubric: state }),
-}));
-jest.mock('data/redux/grading/selectors', () => ({
- selected: {
- gradingStatus: (state) => ({ gradingStatus: state }),
- score: (state) => ({ score: state }),
- userDisplay: (state) => ({ userDisplay: state }),
+jest.unmock('@openedx/paragon');
+jest.unmock('react');
+jest.unmock('@edx/frontend-platform/i18n');
+
+jest.mock('data/redux', () => ({
+ actions: {
+ app: {
+ toggleShowRubric: jest.fn().mockName('actions.app.toggleShowRubric'),
+ },
+ },
+ selectors: {
+ app: {
+ showRubric: jest.fn(state => state.showRubric).mockName('selectors.app.showRubric'),
+ },
+ grading: {
+ selected: {
+ userDisplay: jest.fn(state => state.userDisplay).mockName('selectors.grading.selected.userDisplay'),
+ gradingStatus: jest.fn(state => state.gradingStatus).mockName('selectors.grading.selected.gradingStatus'),
+ score: jest.fn(state => state.score).mockName('selectors.grading.selected.score'),
+ gradeStatus: jest.fn(state => state.gradeStatus).mockName('selectors.grading.selected.gradeStatus'),
+ },
+ selectionLength: jest.fn(state => state.selectionLength).mockName('selectors.grading.selectionLength'),
+ activeIndex: jest.fn(() => 0).mockName('selectors.grading.activeIndex'),
+ next: {
+ doesExist: jest.fn(() => false).mockName('selectors.grading.next.doesExist'),
+ },
+ prev: {
+ doesExist: jest.fn(() => false).mockName('selectors.grading.prev.doesExist'),
+ },
+ },
+ requests: {
+ isCompleted: jest.fn((state, { requestKey }) => state.requests?.[requestKey]).mockName('selectors.requests.isCompleted'),
+ isPending: jest.fn(() => false).mockName('selectors.requests.isPending'),
+ allowNavigation: jest.fn(() => true).mockName('selectors.requests.allowNavigation'),
+ },
+ },
+ thunkActions: {
+ app: {
+ toggleShowRubric: jest.fn().mockName('thunkActions.app.toggleShowRubric'),
+ },
+ grading: {
+ loadNext: jest.fn().mockName('thunkActions.grading.loadNext'),
+ loadPrev: jest.fn().mockName('thunkActions.grading.loadPrev'),
+ startGrading: jest.fn().mockName('thunkActions.grading.startGrading'),
+ cancelGrading: jest.fn().mockName('thunkActions.grading.cancelGrading'),
+ },
},
}));
-jest.mock('data/redux/requests/selectors', () => ({
- isCompleted: (state) => ({ isCompleted: state }),
-}));
-jest.mock('components/StatusBadge', () => 'StatusBadge');
-jest.mock('./components/StartGradingButton', () => 'StartGradingButton');
-jest.mock('./components/SubmissionNavigation', () => 'SubmissionNavigation');
+
+jest.mock('./components/StartGradingButton', () => {
+ const MockStartGradingButton = () => null;
+ return MockStartGradingButton;
+});
+
+jest.mock('./components/SubmissionNavigation', () => {
+ const MockSubmissionNavigation = () => null;
+ return MockSubmissionNavigation;
+});
describe('ReviewActions component', () => {
+ const renderWithIntl = (component) => render(
+
+ {component}
+ ,
+ );
+
describe('component', () => {
const props = {
- gradingStatus: 'grading-status',
+ gradingStatus: 'ungraded',
userDisplay: 'test-userDisplay',
showRubric: false,
score: { pointsEarned: 3, pointsPossible: 10 },
+ toggleShowRubric: jest.fn(),
};
+
beforeEach(() => {
- props.toggleShowRubric = jest.fn().mockName('this.props.toggleShowRubric');
+ jest.clearAllMocks();
});
- test('snapshot: loading', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ it('displays user display name', () => {
+ renderWithIntl();
+ expect(screen.getByText('test-userDisplay')).toBeInTheDocument();
});
- test('snapshot: do not show rubric', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ it('does not show rubric button when not loaded', () => {
+ renderWithIntl();
+ const buttons = screen.queryAllByRole('button');
+ expect(buttons).toHaveLength(0);
});
- test('snapshot: show rubric, no score', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+
+ it('shows rubric button when loaded', () => {
+ renderWithIntl();
+ const buttons = screen.getAllByRole('button');
+ expect(buttons.length).toBeGreaterThan(0);
+ });
+
+ it('calls toggleShowRubric when button is clicked', async () => {
+ renderWithIntl();
+ const button = screen.getByRole('button');
+ const user = userEvent.setup();
+ await user.click(button);
+ expect(props.toggleShowRubric).toHaveBeenCalledTimes(1);
+ });
+
+ it('displays points when pointsPossible is provided', () => {
+ renderWithIntl();
+ const pointsElement = screen.getByText('Score: 3/10');
+ expect(pointsElement).toBeInTheDocument();
+ });
+
+ it('does not display points when pointsPossible is not provided', () => {
+ const propsWithoutPoints = {
+ ...props,
+ score: { pointsEarned: 3, pointsPossible: null },
+ };
+ renderWithIntl();
+ const pointsElement = screen.queryByText(text => text.includes('3'));
+ expect(pointsElement).toBeNull();
});
});
describe('mapStateToProps', () => {
let mapped;
- const testState = { some: 'test-state' };
+ const testState = {
+ showRubric: true,
+ userDisplay: 'test-user',
+ gradingStatus: 'test-status',
+ score: { pointsEarned: 5, pointsPossible: 10 },
+ requests: { [RequestKeys.fetchSubmission]: true },
+ };
+
beforeEach(() => {
mapped = mapStateToProps(testState);
});
- test('isLoaded loads from requests.isCompleted for fetchSubmissions', () => {
- const requestKey = RequestKeys.fetchSubmission;
- expect(mapped.isLoaded).toEqual(selectors.requests.isCompleted(testState, { requestKey }));
+
+ it('maps isLoaded from requests.isCompleted for fetchSubmissions', () => {
+ expect(selectors.requests.isCompleted).toHaveBeenCalledWith(
+ testState,
+ { requestKey: RequestKeys.fetchSubmission },
+ );
+ expect(mapped.isLoaded).toBe(true);
});
- test('userDisplay loads from grading.selected.userDisplay', () => {
- expect(mapped.userDisplay).toEqual(selectors.grading.selected.userDisplay(testState));
+
+ it('maps userDisplay from grading.selected.userDisplay', () => {
+ expect(selectors.grading.selected.userDisplay).toHaveBeenCalledWith(testState);
+ expect(mapped.userDisplay).toBe('test-user');
});
- test('gradingStatus loads from grading.selected.gradingStatus', () => {
- expect(mapped.gradingStatus).toEqual(selectors.grading.selected.gradingStatus(testState));
+
+ it('maps gradingStatus from grading.selected.gradingStatus', () => {
+ expect(selectors.grading.selected.gradingStatus).toHaveBeenCalledWith(testState);
+ expect(mapped.gradingStatus).toBe('test-status');
});
- test('score loads from grading.selected.score', () => {
- expect(mapped.score).toEqual(selectors.grading.selected.score(testState));
+
+ it('maps score from grading.selected.score', () => {
+ expect(selectors.grading.selected.score).toHaveBeenCalledWith(testState);
+ expect(mapped.score).toEqual({ pointsEarned: 5, pointsPossible: 10 });
});
- test('showRubric loads from app.showRubric', () => {
- expect(mapped.showRubric).toEqual(selectors.app.showRubric(testState));
+
+ it('maps showRubric from app.showRubric', () => {
+ expect(selectors.app.showRubric).toHaveBeenCalledWith(testState);
+ expect(mapped.showRubric).toBe(true);
});
});
describe('mapDispatchToProps', () => {
- it('loads toggleShowRubric from actions.app.toggleShowRubric', () => {
+ it('maps toggleShowRubric to actions.app.toggleShowRubric', () => {
expect(mapDispatchToProps.toggleShowRubric).toEqual(actions.app.toggleShowRubric);
});
});