Skip to content

Commit bc5a062

Browse files
committed
chore: update test
1 parent e7f0fd0 commit bc5a062

17 files changed

+66
-74
lines changed

src/components/FileUpload/ActionCell.jsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { useCallback } from 'react';
2-
import { IconButton, Icon } from '@edx/paragon';
2+
import PropTypes from 'prop-types';
33

4-
import { useIntl } from '@edx/frontend-platform/i18n';
4+
import { IconButton, Icon } from '@edx/paragon';
55
import { Delete, Preview } from '@edx/paragon/icons';
6+
import { useIntl } from '@edx/frontend-platform/i18n';
67

78
import messages from './messages';
89

@@ -15,7 +16,7 @@ const ActionCell = ({
1516
const deleteFile = useCallback(async () => {
1617
console.log('deleteFile', row.index);
1718
await onDeletedFile(row.index);
18-
}, []);
19+
}, [onDeletedFile, row.index]);
1920
return (
2021
<>
2122
<IconButton
@@ -35,4 +36,16 @@ const ActionCell = ({
3536
);
3637
};
3738

39+
ActionCell.defaultProps = {
40+
onDeletedFile: () => {},
41+
};
42+
43+
ActionCell.propTypes = {
44+
onDeletedFile: PropTypes.func,
45+
disabled: PropTypes.bool.isRequired,
46+
row: PropTypes.shape({
47+
index: PropTypes.number.isRequired,
48+
}).isRequired,
49+
};
50+
3851
export default ActionCell;

src/components/FileUpload/ActionCell.test.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ import { shallow } from '@edx/react-unit-test-utils';
22
import ActionCell from './ActionCell';
33

44
describe('<ActionCell />', () => {
5+
const props = {
6+
onDeletedFile: jest.fn(),
7+
disabled: false,
8+
row: {
9+
index: 0,
10+
},
11+
};
512
it('renders', () => {
6-
const wrapper = shallow(<ActionCell />);
13+
const wrapper = shallow(<ActionCell {...props} />);
714
expect(wrapper.snapshot).toMatchSnapshot();
815
});
916
});

src/components/FileUpload/__snapshots__/ActionCell.test.jsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ exports[`<ActionCell /> renders 1`] = `
44
<Fragment>
55
<IconButton
66
alt="Delete"
7+
disabled={false}
78
iconAs="Icon"
89
onClick={[Function]}
910
src={[Function]}
1011
/>
1112
<IconButton
1213
alt="Preview"
14+
disabled={false}
1315
iconAs="Icon"
1416
src={[Function]}
1517
/>

src/components/FileUpload/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import messages from './messages';
1414

1515
import './styles.scss';
1616

17-
const FileUpload = ({ isReadOnly, uploadedFiles, onFileUploaded, onDeletedFile }) => {
17+
const FileUpload = ({
18+
isReadOnly, uploadedFiles, onFileUploaded, onDeletedFile,
19+
}) => {
1820
const { formatMessage } = useIntl();
1921

2022
const {
@@ -55,6 +57,7 @@ const FileUpload = ({ isReadOnly, uploadedFiles, onFileUploaded, onDeletedFile }
5557
{
5658
Header: formatMessage(messages.fileActionsTitle),
5759
accessor: 'actions',
60+
// eslint-disable-next-line react/no-unstable-nested-components
5861
Cell: (props) => <ActionCell {...props} onDeletedFile={onDeletedFile} disabled={isReadOnly} />,
5962
},
6063
]}
@@ -82,6 +85,7 @@ FileUpload.defaultProps = {
8285
isReadOnly: false,
8386
uploadedFiles: [],
8487
onFileUploaded: () => { },
88+
onDeletedFile: () => { },
8589
};
8690
FileUpload.propTypes = {
8791
isReadOnly: PropTypes.bool,
@@ -93,6 +97,7 @@ FileUpload.propTypes = {
9397
}),
9498
),
9599
onFileUploaded: PropTypes.func,
100+
onDeletedFile: PropTypes.func,
96101
};
97102

98103
export default FileUpload;

src/components/TextResponse/index.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import RichTextEditor from 'components/TextResponse/RichTextEditor';
66

77
import './index.scss';
88

9-
const TextResponse = ({ submissionConfig, value, onChange, isReadOnly }) => {
9+
const TextResponse = ({
10+
submissionConfig, value, onChange, isReadOnly,
11+
}) => {
1012
const { textResponseConfig } = submissionConfig;
1113
const { optional, enabled } = textResponseConfig;
1214
const props = {
@@ -25,6 +27,11 @@ const TextResponse = ({ submissionConfig, value, onChange, isReadOnly }) => {
2527
);
2628
};
2729

30+
TextResponse.defaultProps = {
31+
onChange: () => {},
32+
isReadOnly: false,
33+
};
34+
2835
TextResponse.propTypes = {
2936
submissionConfig: PropTypes.shape({
3037
textResponseConfig: PropTypes.shape({
@@ -35,6 +42,7 @@ TextResponse.propTypes = {
3542
}).isRequired,
3643
value: PropTypes.string.isRequired,
3744
onChange: PropTypes.func,
45+
isReadOnly: PropTypes.bool,
3846
};
3947

4048
export default TextResponse;

src/views/SelfAssessmentView/AssessmentContent.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4-
import { Icon } from '@edx/paragon';
5-
import { CheckCircle } from '@edx/paragon/icons';
64
import { useIntl } from '@edx/frontend-platform/i18n';
75

86
import Prompt from 'components/Prompt';

src/views/SelfAssessmentView/AssessmentContent.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('<AssessmentContent />', () => {
2424
submissionConfig: {
2525
maxFileSize: 100,
2626
},
27-
}
27+
},
2828
};
2929

3030
describe('render', () => {

src/views/SelfAssessmentView/AssessmentContentLayout.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const AssessmentContentLayout = ({
2121
oraConfigData={oraConfigData}
2222
/>
2323
</Col>
24-
<Rubric isGrading={true} />
24+
<Rubric isGrading />
2525
</Row>
2626
</div>
2727
</div>

src/views/SelfAssessmentView/AssessmentContentLayout.test.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ jest.mock('./AssessmentContent', () => 'AssessmentContent');
66

77
describe('<AssessmentContentLayout />', () => {
88
const props = {
9-
submission: 'submission'
9+
submission: 'submission',
10+
oraConfigData: 'oraConfigData',
1011
};
1112

1213
it('render', () => {

src/views/SelfAssessmentView/__snapshots__/AssessmentContentLayout.test.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ exports[`<AssessmentContentLayout /> render 1`] = `
1414
className="p-0"
1515
>
1616
<AssessmentContent
17+
oraConfigData="oraConfigData"
1718
submission="submission"
1819
/>
1920
</Col>

0 commit comments

Comments
 (0)