Skip to content

Commit

Permalink
temp: experimenting with removing old code
Browse files Browse the repository at this point in the history
  • Loading branch information
ilee2u committed Jan 25, 2024
1 parent 33b85d4 commit d720c88
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/api.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { store } from './data';
describe('External API integration tests', () => {
describe('Test isExam with exam', () => {
beforeAll(() => {
console.log(getState());

Check warning on line 9 in src/api.test.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement

Check failure on line 9 in src/api.test.jsx

View workflow job for this annotation

GitHub Actions / tests

'getState' is not defined

Check warning on line 9 in src/api.test.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement

Check failure on line 9 in src/api.test.jsx

View workflow job for this annotation

GitHub Actions / tests

'getState' is not defined
jest.mock('./data');
const mockExam = Factory.build('exam', { attempt: Factory.build('attempt') });
const mockToken = Factory.build('examAccessToken');
Expand Down
1 change: 1 addition & 0 deletions src/core/ExamStateProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const StateProvider = ({ children, ...state }) => {

const mapStateToProps = (state) => ({ ...state.examState });

// TODO: FIGURE OUT WHAT THIS IS, AND HOW TO GET AROUND IT.
const ExamStateProvider = withExamStore(
StateProvider,
mapStateToProps,
Expand Down
2 changes: 1 addition & 1 deletion src/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export {
examRequiresAccessToken,
} from './thunks';

export { default as store } from './store';
// export { default as store } from './store';
export { default as Emitter } from './emitter';
8 changes: 6 additions & 2 deletions src/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ const EXAM_START_TIMEOUT_MILLISECONDS = 5000;
* @param noLoading - if set to false shows spinner while executing the function
*/
function updateAttemptAfter(courseId, sequenceId, promiseToBeResolvedFirst = null, noLoading = false) {
return async (dispatch) => {
return async (dispatch, getState) => {
// TODO: Figure out where the heck this getState is supposed to come from????
// And also remove the getState from this thunk b/c it was not here originally...
const { exam } = getState().examState;
if (!noLoading) { dispatch(setIsLoading({ isLoading: true })); }
if (promiseToBeResolvedFirst) {
try {
Expand All @@ -66,6 +69,7 @@ function updateAttemptAfter(courseId, sequenceId, promiseToBeResolvedFirst = nul
}
try {
const attemptData = await fetchExamAttemptsData(courseId, sequenceId);
console.log("EXAM:", exam);

Check warning on line 72 in src/data/thunks.js

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement

Check failure on line 72 in src/data/thunks.js

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote

Check warning on line 72 in src/data/thunks.js

View workflow job for this annotation

GitHub Actions / tests

Unexpected console statement

Check failure on line 72 in src/data/thunks.js

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote
dispatch(setExamState({
exam: attemptData.exam,
activeAttempt: !isEmpty(attemptData.active_attempt) ? attemptData.active_attempt : null,
Expand All @@ -83,7 +87,7 @@ export function getExamAttemptsData(courseId, sequenceId) {
}

export function getLatestAttemptData(courseId) {
return async (dispatch) => {
return async (dispatch, getState) => {

Check failure on line 90 in src/data/thunks.js

View workflow job for this annotation

GitHub Actions / tests

'getState' is defined but never used

Check failure on line 90 in src/data/thunks.js

View workflow job for this annotation

GitHub Actions / tests

'getState' is defined but never used
dispatch(setIsLoading({ isLoading: true }));
try {
const attemptData = await fetchLatestAttempt(courseId);
Expand Down
2 changes: 1 addition & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export {
isExam,
fetchExamAccess,
} from './api';
export { store } from './data';
// export { store } from './data';
export { reducer } from './data/slice';

0 comments on commit d720c88

Please sign in to comment.