fix: update tests for createSlice refactor

This commit is contained in:
Ben Warzeski
2021-11-05 01:25:57 -04:00
parent a9252dedd2
commit 3e6eb4b269
8 changed files with 45 additions and 35 deletions

View File

@@ -1,8 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import actions from 'data/actions';
import selectors from 'data/selectors';
import { actions, selectors } from 'data/redux';
import {
feedbackRequirement,
gradeStatuses,

View File

@@ -37,9 +37,19 @@ jest.mock('components/StatusBadge', () => 'StatusBadge');
jest.mock('containers/ReviewModal', () => 'ReviewModal');
jest.mock('./ListViewBreadcrumb', () => 'ListViewBreadcrumb');
jest.mock('data/redux/submissions/selectors', () => ({
submissions: {
listData: (...args) => ({ listData: args }),
jest.mock('data/redux', () => ({
selectors: {
submissions: {
listData: (...args) => ({ listData: args }),
},
},
thunkActions: {
app: {
initialize: (...args) => ({ initialize: args }),
},
grading: {
loadSelectionForReview: (...args) => ({ loadSelectionForReview: args }),
},
},
}));

View File

@@ -4,8 +4,8 @@ import { shallow } from 'enzyme';
import createDOMPurify from 'dompurify';
import parse from 'html-react-parser';
import selectors from 'data/selectors';
import { fileUploadResponseOptions } from 'data/services/lms/constants';
import { selectors } from 'data/redux';
import { ResponseDisplay, mapStateToProps } from '.';
@@ -17,9 +17,8 @@ jest.mock('@edx/paragon', () => {
};
});
jest.mock('data/selectors', () => ({
__esModule: true,
default: {
jest.mock('data/redux', () => ({
selectors: {
grading: {
selected: {
response: (state) => ({ response: state }),

View File

@@ -14,7 +14,9 @@ exports[`Rubric Container snapshot is grading 1`] = `
id="ora-grading.Rubric.rubric"
/>
</h3>
<hr />
<hr
className="m-2.5"
/>
<CriterionContainer
isGrading={true}
key="1"
@@ -71,7 +73,9 @@ exports[`Rubric Container snapshot is not grading 1`] = `
id="ora-grading.Rubric.rubric"
/>
</h3>
<hr />
<hr
className="m-2.5"
/>
<CriterionContainer
isGrading={false}
key="1"

View File

@@ -13,25 +13,21 @@ jest.mock('./requests', () => ({
}));
jest.mock('data/redux/app/selectors', () => ({
app: {
emptyGrade: (state) => ({ emptyGrade: state }),
},
emptyGrade: (state) => ({ emptyGrade: state }),
}));
jest.mock('data/redux/grading/selectors', () => ({
grading: {
prev: {
submissionId: (state) => ({ prevSubmissionId: state }),
doesExist: jest.fn((state) => ({ prevDoesExist: state })),
},
next: {
submissionId: (state) => ({ prevSubmissionId: state }),
doesExist: jest.fn((state) => ({ nextDoesExist: state })),
},
selected: {
submissionId: (state) => ({ selectedSubmissionId: state }),
gradeData: jest.fn((state) => ({ gradeData: state })),
},
prev: {
submissionId: (state) => ({ prevSubmissionId: state }),
doesExist: jest.fn((state) => ({ prevDoesExist: state })),
},
next: {
submissionId: (state) => ({ prevSubmissionId: state }),
doesExist: jest.fn((state) => ({ nextDoesExist: state })),
},
selected: {
submissionId: (state) => ({ selectedSubmissionId: state }),
gradeData: jest.fn((state) => ({ gradeData: state })),
},
}));

View File

@@ -3,15 +3,16 @@ import thunkMiddleware from 'redux-thunk';
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
import { createLogger } from 'redux-logger';
import actions from './actions';
import selectors from './selectors';
import reducers from './reducers';
import rootReducer, { actions, selectors } from 'data/redux';
import exportedStore, { createStore } from './store';
jest.mock('./reducers', () => 'REDUCER');
jest.mock('./actions', () => 'ACTIONS');
jest.mock('./selectors', () => 'SELECTORS');
jest.mock('data/redux', () => ({
__esModule: true,
default: 'REDUCER',
actions: 'ACTIONS',
selectors: 'SELECTORS',
}));
jest.mock('redux-logger', () => ({
createLogger: () => 'logger',
@@ -31,7 +32,7 @@ describe('store aggregator module', () => {
expect(exportedStore).toEqual(createStore());
});
it('creates store with connected reducers', () => {
expect(createStore().reducer).toEqual(reducers);
expect(createStore().reducer).toEqual(rootReducer);
});
describe('middleware', () => {
it('exports thunk and logger middleware, composed and applied with dev tools', () => {

View File

@@ -16,6 +16,7 @@ jest.mock('react-dom', () => ({
render: jest.fn(),
}));
jest.mock('@edx/frontend-platform', () => ({
...jest.requireActual('@edx/frontend-platform'),
APP_READY: 'app-is-ready-key',
initialize: jest.fn(),
subscribe: jest.fn(),

View File

@@ -14,7 +14,7 @@ import { IntlProvider } from '@edx/frontend-platform/i18n';
import fakeData from 'data/services/lms/fakeData';
import api from 'data/services/lms/api';
import reducers from 'data/reducers';
import reducers from 'data/redux';
import { gradingStatuses } from 'data/services/lms/constants';
import messages from 'i18n';
import reviewActionsMessages from 'containers/ReviewActions/messages';