Skip to content

Commit

Permalink
chore: update left over test
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Jan 31, 2024
1 parent e81b84d commit d73d03b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/components/CriterionContainer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ CriterionContainer.propTypes = {
options: PropTypes.arrayOf(
PropTypes.shape({
name: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
}),
).isRequired,
Expand Down
16 changes: 5 additions & 11 deletions src/hooks/actions/useLoadNextAction.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React from 'react';
import { useIntl } from '@edx/frontend-platform/i18n';

import {
usePageDataStatus,
useRefreshPageData,
useStepInfo,
} from 'hooks/app';
import { usePageDataStatus, useRefreshPageData, useStepInfo } from 'hooks/app';
import { useResetAssessment } from 'hooks/assessment';
import { useEffectiveStep } from 'hooks/routing';
import { useIsMounted } from 'hooks/utils';
Expand All @@ -22,16 +18,14 @@ export default () => {
const stepInfo = useStepInfo();
const step = useEffectiveStep();
if (
!(
step === stepNames.studentTraining
|| (step === stepNames.peer)
|| (step === stepNames.peer && !stepInfo.peer?.isWaitingForSubmissions)
)
![stepNames.studentTraining, stepNames.peer].includes(step) ||

Check failure on line 21 in src/hooks/actions/useLoadNextAction.js

View workflow job for this annotation

GitHub Actions / test

'||' should be placed at the beginning of the line
(step === stepNames.peer && stepInfo.peer?.isWaitingForSubmissions)
) {
return null;
}

const label = (message) => `${formatMessage(message)} ${formatMessage(loadNextSteps[step])}`;
const label = (message) =>
`${formatMessage(message)} ${formatMessage(loadNextSteps[step])}`;

Check failure on line 28 in src/hooks/actions/useLoadNextAction.js

View workflow job for this annotation

GitHub Actions / test

Expected no linebreak before this expression

return {
action: {
Expand Down
16 changes: 3 additions & 13 deletions src/hooks/routing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useLocation } from 'react-router-dom';
import { useActiveStepName } from 'data/services/lms/hooks/selectors';
import { routeSteps, stepNames } from 'constants/index';
import { routeSteps } from 'constants/index';
import { isXblockStep } from 'utils';

export const hooks = {
/**
Expand All @@ -18,16 +19,6 @@ Object.assign(hooks, {
*/
useViewStep: () => routeSteps[hooks.useActiveView()],
});
Object.assign(hooks, {
/**
* isXblockStep(step)
* @description returns true if the step is an xblock step
* @param {string} step - step to check
* @returns {boolean} true if the step is an xblock step
*/
isXblockStep: (step) => [stepNames.xblock, stepNames.xblockStudio, stepNames.xblockPreview].includes(step),
});

Object.assign(hooks, {
/**
* useEffectiveStep()
Expand All @@ -37,12 +28,11 @@ Object.assign(hooks, {
useEffectiveStep: () => {
const viewStep = hooks.useViewStep();
const activeStep = useActiveStepName();
return hooks.isXblockStep(isXblockStep) ? activeStep : viewStep;
return isXblockStep(viewStep) ? activeStep : viewStep;
},
});
export const {
useActiveView,
useViewStep,
useEffectiveStep,
isXblockStep,
} = hooks;
11 changes: 10 additions & 1 deletion src/utils/isXblockStep.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import { stepNames } from 'constants/index';

export default (step) => [stepNames.xblock, stepNames.xblockStudio, stepNames.xblockPreview].includes(step);
/**
* isXblockStep(step)
* @description returns true if the step is an xblock step
* @param {string} step - step to check
* @returns {boolean} true if the step is an xblock step
*/
export default (step) =>
[stepNames.xblock, stepNames.xblockStudio, stepNames.xblockPreview].includes(

Check failure on line 10 in src/utils/isXblockStep.js

View workflow job for this annotation

GitHub Actions / test

Expected no linebreak before this expression
step

Check failure on line 11 in src/utils/isXblockStep.js

View workflow job for this annotation

GitHub Actions / test

Missing trailing comma
);
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"components": ["components/*"],
"constants": ["constants/*"],
"views": ["views/*"],
"utils": ["utils/*"]
"utils": ["utils/*"],
"hooks": ["hooks/*"],
}
},
"include": ["src"],
Expand Down

0 comments on commit d73d03b

Please sign in to comment.