@pie-lib/rubric 2.0.4-next.3 → 2.0.4-next.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.js +7 -0
- package/dist/authoring.d.ts +62 -0
- package/dist/authoring.js +298 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +9 -0
- package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/dist/node_modules/.bun/@hello-pangea_dnd@18.0.1_d0d44917b9a63a72/node_modules/@hello-pangea/dnd/dist/dnd.esm.js +4451 -0
- package/dist/node_modules/.bun/css-box-model@1.2.1/node_modules/css-box-model/dist/css-box-model.esm.js +102 -0
- package/dist/node_modules/.bun/raf-schd@4.0.3/node_modules/raf-schd/dist/raf-schd.esm.js +13 -0
- package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +471 -0
- package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +159 -0
- package/dist/node_modules/.bun/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +11 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +53 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +51 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +10 -0
- package/dist/point-menu.d.ts +27 -0
- package/dist/point-menu.js +73 -0
- package/package.json +35 -12
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -1448
- package/LICENSE.md +0 -5
- package/lib/authoring.js +0 -496
- package/lib/authoring.js.map +0 -1
- package/lib/index.js +0 -20
- package/lib/index.js.map +0 -1
- package/lib/point-menu.js +0 -125
- package/lib/point-menu.js.map +0 -1
- package/src/__tests__/rubric.test.jsx +0 -373
- package/src/authoring.jsx +0 -413
- package/src/index.js +0 -9
- package/src/point-menu.jsx +0 -87
package/lib/point-menu.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = exports.IconMenu = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
var _Menu = _interopRequireDefault(require("@mui/material/Menu"));
|
|
15
|
-
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
16
|
-
var _MoreVert = _interopRequireDefault(require("@mui/icons-material/MoreVert"));
|
|
17
|
-
var _MoreHoriz = _interopRequireDefault(require("@mui/icons-material/MoreHoriz"));
|
|
18
|
-
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
19
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
20
|
-
var _react = _interopRequireDefault(require("react"));
|
|
21
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
22
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
23
|
-
var IconMenu = exports.IconMenu = /*#__PURE__*/function (_React$Component) {
|
|
24
|
-
function IconMenu(props) {
|
|
25
|
-
var _this;
|
|
26
|
-
(0, _classCallCheck2["default"])(this, IconMenu);
|
|
27
|
-
_this = _callSuper(this, IconMenu, [props]);
|
|
28
|
-
(0, _defineProperty2["default"])(_this, "handleClick", function (event) {
|
|
29
|
-
return _this.setState({
|
|
30
|
-
open: true,
|
|
31
|
-
anchorEl: event.currentTarget
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
(0, _defineProperty2["default"])(_this, "handleRequestClose", function () {
|
|
35
|
-
return _this.setState({
|
|
36
|
-
open: false
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
_this.state = {
|
|
40
|
-
anchorEl: undefined,
|
|
41
|
-
open: false
|
|
42
|
-
};
|
|
43
|
-
return _this;
|
|
44
|
-
}
|
|
45
|
-
(0, _inherits2["default"])(IconMenu, _React$Component);
|
|
46
|
-
return (0, _createClass2["default"])(IconMenu, [{
|
|
47
|
-
key: "render",
|
|
48
|
-
value: function render() {
|
|
49
|
-
var _this2 = this;
|
|
50
|
-
var _this$props = this.props,
|
|
51
|
-
opts = _this$props.opts,
|
|
52
|
-
onClick = _this$props.onClick;
|
|
53
|
-
var _this$state = this.state,
|
|
54
|
-
open = _this$state.open,
|
|
55
|
-
anchorEl = _this$state.anchorEl;
|
|
56
|
-
var keys = Object.keys(opts) || [];
|
|
57
|
-
var handleMenuClick = function handleMenuClick(key) {
|
|
58
|
-
return function () {
|
|
59
|
-
onClick(key);
|
|
60
|
-
_this2.handleRequestClose();
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
var iconColor = open ? 'inherit' : 'disabled';
|
|
64
|
-
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
65
|
-
onClick: this.handleClick
|
|
66
|
-
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
67
|
-
size: "large"
|
|
68
|
-
}, open ? /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], {
|
|
69
|
-
color: iconColor
|
|
70
|
-
}) : /*#__PURE__*/_react["default"].createElement(_MoreHoriz["default"], {
|
|
71
|
-
color: iconColor
|
|
72
|
-
}))), /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
|
|
73
|
-
id: "point-menu",
|
|
74
|
-
anchorEl: anchorEl,
|
|
75
|
-
open: open,
|
|
76
|
-
onClose: this.handleRequestClose,
|
|
77
|
-
style: {
|
|
78
|
-
transform: 'translate(-15px, -15px)'
|
|
79
|
-
},
|
|
80
|
-
transformOrigin: {
|
|
81
|
-
vertical: 'center',
|
|
82
|
-
horizontal: 'right'
|
|
83
|
-
}
|
|
84
|
-
}, keys.map(function (k, index) {
|
|
85
|
-
return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
86
|
-
key: index,
|
|
87
|
-
onClick: handleMenuClick(k)
|
|
88
|
-
}, opts[k]);
|
|
89
|
-
})));
|
|
90
|
-
}
|
|
91
|
-
}]);
|
|
92
|
-
}(_react["default"].Component);
|
|
93
|
-
(0, _defineProperty2["default"])(IconMenu, "propTypes", {
|
|
94
|
-
opts: _propTypes["default"].object,
|
|
95
|
-
onClick: _propTypes["default"].func.isRequired
|
|
96
|
-
});
|
|
97
|
-
var PointMenu = exports["default"] = /*#__PURE__*/function (_React$Component2) {
|
|
98
|
-
function PointMenu() {
|
|
99
|
-
(0, _classCallCheck2["default"])(this, PointMenu);
|
|
100
|
-
return _callSuper(this, PointMenu, arguments);
|
|
101
|
-
}
|
|
102
|
-
(0, _inherits2["default"])(PointMenu, _React$Component2);
|
|
103
|
-
return (0, _createClass2["default"])(PointMenu, [{
|
|
104
|
-
key: "render",
|
|
105
|
-
value: function render() {
|
|
106
|
-
var _this$props2 = this.props,
|
|
107
|
-
onChange = _this$props2.onChange,
|
|
108
|
-
showSampleAnswer = _this$props2.showSampleAnswer;
|
|
109
|
-
var sampleText = showSampleAnswer ? 'Provide Sample Response' : 'Remove Sample Response';
|
|
110
|
-
return /*#__PURE__*/_react["default"].createElement(IconMenu, {
|
|
111
|
-
onClick: function onClick(key) {
|
|
112
|
-
return onChange(key);
|
|
113
|
-
},
|
|
114
|
-
opts: {
|
|
115
|
-
sample: sampleText
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}]);
|
|
120
|
-
}(_react["default"].Component);
|
|
121
|
-
(0, _defineProperty2["default"])(PointMenu, "propTypes", {
|
|
122
|
-
onChange: _propTypes["default"].func.isRequired,
|
|
123
|
-
showSampleAnswer: _propTypes["default"].bool.isRequired
|
|
124
|
-
});
|
|
125
|
-
//# sourceMappingURL=point-menu.js.map
|
package/lib/point-menu.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"point-menu.js","names":["_Menu","_interopRequireDefault","require","_MenuItem","_MoreVert","_MoreHoriz","_IconButton","_propTypes","_react","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","IconMenu","exports","_React$Component","props","_this","_classCallCheck2","_defineProperty2","event","setState","open","anchorEl","currentTarget","state","undefined","_inherits2","_createClass2","key","value","render","_this2","_this$props","opts","onClick","_this$state","keys","Object","handleMenuClick","handleRequestClose","iconColor","createElement","handleClick","size","color","id","onClose","style","transform","transformOrigin","vertical","horizontal","map","k","index","React","Component","PropTypes","object","func","isRequired","PointMenu","_React$Component2","arguments","_this$props2","onChange","showSampleAnswer","sampleText","sample","bool"],"sources":["../src/point-menu.jsx"],"sourcesContent":["import Menu from '@mui/material/Menu';\nimport MenuItem from '@mui/material/MenuItem';\nimport MoreVertIcon from '@mui/icons-material/MoreVert';\nimport MoreHorizIcon from '@mui/icons-material/MoreHoriz';\nimport IconButton from '@mui/material/IconButton';\nimport PropTypes from 'prop-types';\nimport React from 'react';\n\nexport class IconMenu extends React.Component {\n static propTypes = {\n opts: PropTypes.object,\n onClick: PropTypes.func.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n anchorEl: undefined,\n open: false,\n };\n }\n\n handleClick = (event) => this.setState({ open: true, anchorEl: event.currentTarget });\n\n handleRequestClose = () => this.setState({ open: false });\n\n render() {\n const { opts, onClick } = this.props;\n const { open, anchorEl } = this.state;\n const keys = Object.keys(opts) || [];\n\n const handleMenuClick = (key) => () => {\n onClick(key);\n this.handleRequestClose();\n };\n\n const iconColor = open ? 'inherit' : 'disabled';\n\n return (\n <div>\n <div onClick={this.handleClick}>\n <IconButton size=\"large\">\n {open ? <MoreVertIcon color={iconColor} /> : <MoreHorizIcon color={iconColor} />}\n </IconButton>\n </div>\n <Menu\n id=\"point-menu\"\n anchorEl={anchorEl}\n open={open}\n onClose={this.handleRequestClose}\n style={{ transform: 'translate(-15px, -15px)' }}\n transformOrigin={{\n vertical: 'center',\n horizontal: 'right',\n }}\n >\n {keys.map((k, index) => (\n <MenuItem key={index} onClick={handleMenuClick(k)}>\n {opts[k]}\n </MenuItem>\n ))}\n </Menu>\n </div>\n );\n }\n}\n\nexport default class PointMenu extends React.Component {\n static propTypes = {\n onChange: PropTypes.func.isRequired,\n showSampleAnswer: PropTypes.bool.isRequired,\n };\n\n render() {\n const { onChange, showSampleAnswer } = this.props;\n const sampleText = showSampleAnswer ? 'Provide Sample Response' : 'Remove Sample Response';\n\n return (\n <IconMenu\n onClick={(key) => onChange(key)}\n opts={{\n sample: sampleText,\n }}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CA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A6C,aAAA,CAAC7B,QAAQ;QACPsB,OAAO,EAAE,SAATA,OAAOA,CAAGN,GAAG;UAAA,OAAKqC,QAAQ,CAACrC,GAAG,CAAC;QAAA,CAAC;QAChCK,IAAI,EAAE;UACJmC,MAAM,EAAED;QACV;MAAE,CACH,CAAC;IAEN;EAAC;AAAA,EAlBoCZ,iBAAK,CAACC,SAAS;AAAA,IAAAtC,gBAAA,aAAjC2C,SAAS,eACT;EACjBI,QAAQ,EAAER,qBAAS,CAACE,IAAI,CAACC,UAAU;EACnCM,gBAAgB,EAAET,qBAAS,CAACY,IAAI,CAACT;AACnC,CAAC","ignoreList":[]}
|
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { RawAuthoring } from '../authoring';
|
|
4
|
-
import { takeRight } from 'lodash-es';
|
|
5
|
-
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
6
|
-
|
|
7
|
-
// Mock dependencies
|
|
8
|
-
jest.mock('@pie-lib/editable-html-tip-tap', () => {
|
|
9
|
-
return function EditableHtml(props) {
|
|
10
|
-
return <div data-testid="editable-html" data-markup={props.markup} />;
|
|
11
|
-
};
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
jest.mock('@pie-lib/config-ui', () => ({
|
|
15
|
-
FeedbackConfig: ({ feedback }) => <div data-testid="feedback-config">{JSON.stringify(feedback)}</div>,
|
|
16
|
-
InputContainer: ({ children, label }) => (
|
|
17
|
-
<div data-testid="input-container" data-label={label}>
|
|
18
|
-
{children}
|
|
19
|
-
</div>
|
|
20
|
-
),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
jest.mock('@hello-pangea/dnd', () => ({
|
|
24
|
-
DragDropContext: ({ children }) => <div data-testid="drag-drop-context">{children}</div>,
|
|
25
|
-
Droppable: ({ children }) => children({ droppableProps: {}, innerRef: () => {} }, {}),
|
|
26
|
-
Draggable: ({ children, index }) =>
|
|
27
|
-
children(
|
|
28
|
-
{
|
|
29
|
-
innerRef: () => {},
|
|
30
|
-
draggableProps: { 'data-draggable-index': index },
|
|
31
|
-
dragHandleProps: {},
|
|
32
|
-
},
|
|
33
|
-
{},
|
|
34
|
-
),
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
describe('Rubric', () => {
|
|
38
|
-
const points = ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'];
|
|
39
|
-
const sampleAnswers = [null, 'just right', 'not left', null];
|
|
40
|
-
const theme = createTheme();
|
|
41
|
-
|
|
42
|
-
const renderComponent = (value = {}, props = {}) => {
|
|
43
|
-
const defaultProps = {
|
|
44
|
-
classes: {},
|
|
45
|
-
onChange: jest.fn(),
|
|
46
|
-
className: 'className',
|
|
47
|
-
value: {
|
|
48
|
-
excludeZero: false,
|
|
49
|
-
points,
|
|
50
|
-
sampleAnswers,
|
|
51
|
-
...value,
|
|
52
|
-
},
|
|
53
|
-
...props,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
...render(
|
|
58
|
-
<ThemeProvider theme={theme}>
|
|
59
|
-
<RawAuthoring {...defaultProps} />
|
|
60
|
-
</ThemeProvider>,
|
|
61
|
-
),
|
|
62
|
-
onChange: defaultProps.onChange,
|
|
63
|
-
props: defaultProps,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
describe('render', () => {
|
|
68
|
-
it('renders rubric title and main structure', () => {
|
|
69
|
-
renderComponent();
|
|
70
|
-
expect(screen.getByText('Rubric')).toBeInTheDocument();
|
|
71
|
-
expect(screen.getByLabelText('Max Points')).toBeInTheDocument();
|
|
72
|
-
expect(screen.getByLabelText('Exclude zeros')).toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('renders all point configurations', () => {
|
|
76
|
-
const { container } = renderComponent();
|
|
77
|
-
// Verify DragDropContext is rendered
|
|
78
|
-
expect(container.querySelector('[data-testid="drag-drop-context"]')).toBeInTheDocument();
|
|
79
|
-
|
|
80
|
-
// Check that point labels are rendered (4 points = "3 pts", "2 pts", "1 pt", "0 pt")
|
|
81
|
-
// Note: The PointConfig component uses singular "pt" for 0 and 1, plural "pts" for 2+
|
|
82
|
-
expect(screen.getByText('3 pts')).toBeInTheDocument();
|
|
83
|
-
expect(screen.getByText('2 pts')).toBeInTheDocument();
|
|
84
|
-
expect(screen.getByText('1 pt')).toBeInTheDocument();
|
|
85
|
-
expect(screen.getByText('0 pt')).toBeInTheDocument();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('draggable', () => {
|
|
89
|
-
it('renders 3 draggable items when excludeZero is true', () => {
|
|
90
|
-
// When excludeZero is true, the last point (0 pts) should not be rendered
|
|
91
|
-
expect(screen.queryByText('0 pt')).not.toBeInTheDocument();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('renders 4 draggable items when excludeZero is false', () => {
|
|
95
|
-
const { container } = renderComponent({ excludeZero: false });
|
|
96
|
-
|
|
97
|
-
// When excludeZero is false, all points including 0 should be rendered
|
|
98
|
-
const draggableItems = container.querySelectorAll('[data-draggable-index]');
|
|
99
|
-
expect(draggableItems.length).toEqual(4);
|
|
100
|
-
expect(screen.getByText('0 pt')).toBeInTheDocument();
|
|
101
|
-
|
|
102
|
-
// Verify all point labels are rendered
|
|
103
|
-
expect(screen.getByText('3 pts')).toBeInTheDocument();
|
|
104
|
-
expect(screen.getByText('2 pts')).toBeInTheDocument();
|
|
105
|
-
expect(screen.getByText('1 pt')).toBeInTheDocument();
|
|
106
|
-
expect(screen.getByText('0 pt')).toBeInTheDocument();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('logic', () => {
|
|
112
|
-
describe('changeMaxPoints', () => {
|
|
113
|
-
const testChangeMaxPoints = (maxPoints, excludeZero, expectedPoints, expectedSampleAnswers) => {
|
|
114
|
-
it(`maxPoints=${maxPoints}, excludeZero=${excludeZero} calls onChange correctly`, () => {
|
|
115
|
-
const { onChange, container } = renderComponent({ excludeZero });
|
|
116
|
-
|
|
117
|
-
// Get the component instance through the container
|
|
118
|
-
// We need to call the method directly since we're testing internal behavior
|
|
119
|
-
const instance = container.querySelector('[class*="MuiBox-root"]')?._owner;
|
|
120
|
-
|
|
121
|
-
// Since we can't easily access instance methods in RTL, we'll test the behavior
|
|
122
|
-
// by verifying the onChange prop receives the correct values
|
|
123
|
-
// For now, we'll directly test the logic
|
|
124
|
-
const component = new RawAuthoring({
|
|
125
|
-
value: { excludeZero, points, sampleAnswers },
|
|
126
|
-
onChange,
|
|
127
|
-
classes: {},
|
|
128
|
-
className: 'className',
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
component.changeMaxPoints(maxPoints);
|
|
132
|
-
|
|
133
|
-
expect(onChange).toHaveBeenCalledWith({
|
|
134
|
-
excludeZero,
|
|
135
|
-
points: expectedPoints,
|
|
136
|
-
sampleAnswers: expectedSampleAnswers,
|
|
137
|
-
maxPoints: expectedPoints.length - 1,
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
testChangeMaxPoints(1, false, takeRight(points, 2), takeRight(sampleAnswers, 2));
|
|
143
|
-
testChangeMaxPoints(1, true, takeRight(points, 2), takeRight(sampleAnswers, 2));
|
|
144
|
-
testChangeMaxPoints(2, true, takeRight(points, 3), takeRight(sampleAnswers, 3));
|
|
145
|
-
testChangeMaxPoints(2, false, takeRight(points, 3), takeRight(sampleAnswers, 3));
|
|
146
|
-
testChangeMaxPoints(5, false, ['', ''].concat(points), [null, null].concat(sampleAnswers));
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
describe('changeSampleResponse', () => {
|
|
150
|
-
const testChangeSampleResponse = (index, clickedItem, excludeZero, expectedPoints, expectedSampleAnswers) => {
|
|
151
|
-
it(`Point ${index} with clickedItem="${clickedItem}" calls onChange correctly`, () => {
|
|
152
|
-
const { onChange } = renderComponent({ excludeZero });
|
|
153
|
-
|
|
154
|
-
// Test the logic by creating a component instance and calling the method
|
|
155
|
-
const component = new RawAuthoring({
|
|
156
|
-
value: { excludeZero, points, sampleAnswers },
|
|
157
|
-
onChange,
|
|
158
|
-
classes: {},
|
|
159
|
-
className: 'className',
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
component.onPointMenuChange(index, clickedItem);
|
|
163
|
-
|
|
164
|
-
expect(onChange).toHaveBeenCalledWith({
|
|
165
|
-
excludeZero,
|
|
166
|
-
points: expectedPoints,
|
|
167
|
-
sampleAnswers: expectedSampleAnswers,
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
testChangeSampleResponse(0, 'sample', false, points, ['', 'just right', 'not left', null]);
|
|
173
|
-
testChangeSampleResponse(3, 'sample', false, points, [null, 'just right', 'not left', '']);
|
|
174
|
-
testChangeSampleResponse(1, 'sample', true, points, [null, null, 'not left', null]);
|
|
175
|
-
testChangeSampleResponse(3, 'sample', true, points, [null, 'just right', 'not left', '']);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe('user interactions', () => {
|
|
180
|
-
it('calls onChange when excluding zeros checkbox is toggled', () => {
|
|
181
|
-
const { onChange } = renderComponent({ excludeZero: false });
|
|
182
|
-
|
|
183
|
-
const checkbox = screen.getByLabelText('Exclude zeros');
|
|
184
|
-
fireEvent.click(checkbox);
|
|
185
|
-
|
|
186
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
187
|
-
expect.objectContaining({
|
|
188
|
-
excludeZero: true,
|
|
189
|
-
}),
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('calls onChange when max points is changed', () => {
|
|
194
|
-
const { onChange } = renderComponent();
|
|
195
|
-
|
|
196
|
-
const selectInput = screen.getByLabelText('Max Points');
|
|
197
|
-
fireEvent.mouseDown(selectInput);
|
|
198
|
-
|
|
199
|
-
// The onChange should be called when a new value is selected
|
|
200
|
-
// This tests the changeMaxPoints logic indirectly
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('renders correct number of points based on excludeZero', () => {
|
|
204
|
-
const { rerender } = renderComponent({ excludeZero: false });
|
|
205
|
-
expect(screen.getByText('0 pt')).toBeInTheDocument();
|
|
206
|
-
|
|
207
|
-
// Rerender with excludeZero true
|
|
208
|
-
rerender(
|
|
209
|
-
<ThemeProvider theme={theme}>
|
|
210
|
-
<RawAuthoring
|
|
211
|
-
classes={{}}
|
|
212
|
-
onChange={jest.fn()}
|
|
213
|
-
className="className"
|
|
214
|
-
value={{ excludeZero: true, points, sampleAnswers }}
|
|
215
|
-
/>
|
|
216
|
-
</ThemeProvider>,
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
expect(screen.queryByText('0 pt')).not.toBeInTheDocument();
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
describe('drag and drop', () => {
|
|
224
|
-
it('calls onChange with reordered points after drag end', () => {
|
|
225
|
-
const { onChange } = renderComponent();
|
|
226
|
-
|
|
227
|
-
const component = new RawAuthoring({
|
|
228
|
-
value: { excludeZero: false, points, sampleAnswers },
|
|
229
|
-
onChange,
|
|
230
|
-
classes: {},
|
|
231
|
-
className: 'className',
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// Simulate drag from index 0 to index 2
|
|
235
|
-
component.dragEnd({
|
|
236
|
-
source: { index: 0 },
|
|
237
|
-
destination: { index: 2 },
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
expect(onChange).toHaveBeenCalled();
|
|
241
|
-
const result = onChange.mock.calls[0][0];
|
|
242
|
-
expect(result.points).not.toEqual(points);
|
|
243
|
-
expect(result.points.length).toBe(points.length);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('does nothing when drag has no destination', () => {
|
|
247
|
-
const { onChange } = renderComponent();
|
|
248
|
-
|
|
249
|
-
const component = new RawAuthoring({
|
|
250
|
-
value: { excludeZero: false, points, sampleAnswers },
|
|
251
|
-
onChange,
|
|
252
|
-
classes: {},
|
|
253
|
-
className: 'className',
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// Simulate drag without destination
|
|
257
|
-
component.dragEnd({
|
|
258
|
-
source: { index: 0 },
|
|
259
|
-
destination: null,
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
describe('content editing', () => {
|
|
267
|
-
it('calls onChange when point content is changed', () => {
|
|
268
|
-
const { onChange } = renderComponent();
|
|
269
|
-
|
|
270
|
-
const component = new RawAuthoring({
|
|
271
|
-
value: { excludeZero: false, points, sampleAnswers },
|
|
272
|
-
onChange,
|
|
273
|
-
classes: {},
|
|
274
|
-
className: 'className',
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
component.changeContent(0, 'new content', 'points');
|
|
278
|
-
|
|
279
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
280
|
-
expect.objectContaining({
|
|
281
|
-
points: expect.arrayContaining(['new content']),
|
|
282
|
-
}),
|
|
283
|
-
);
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('calls onChange when sample answer is changed', () => {
|
|
287
|
-
const { onChange } = renderComponent();
|
|
288
|
-
|
|
289
|
-
const component = new RawAuthoring({
|
|
290
|
-
value: { excludeZero: false, points, sampleAnswers },
|
|
291
|
-
onChange,
|
|
292
|
-
classes: {},
|
|
293
|
-
className: 'className',
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
component.changeContent(1, 'new sample answer', 'sampleAnswers');
|
|
297
|
-
|
|
298
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
299
|
-
expect.objectContaining({
|
|
300
|
-
sampleAnswers: expect.arrayContaining(['new sample answer']),
|
|
301
|
-
}),
|
|
302
|
-
);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it('does not change content for invalid type', () => {
|
|
306
|
-
const { onChange } = renderComponent();
|
|
307
|
-
|
|
308
|
-
const component = new RawAuthoring({
|
|
309
|
-
value: { excludeZero: false, points, sampleAnswers },
|
|
310
|
-
onChange,
|
|
311
|
-
classes: {},
|
|
312
|
-
className: 'className',
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
component.changeContent(0, 'new content', 'invalidType');
|
|
316
|
-
|
|
317
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
describe('rubricless mode', () => {
|
|
322
|
-
it('calls onChange when rubricless instruction is changed', () => {
|
|
323
|
-
const { onChange } = renderComponent({ rubriclessInstruction: '' }, { rubricless: true });
|
|
324
|
-
|
|
325
|
-
const component = new RawAuthoring({
|
|
326
|
-
value: { excludeZero: false, points, sampleAnswers, rubriclessInstruction: '' },
|
|
327
|
-
onChange,
|
|
328
|
-
classes: {},
|
|
329
|
-
className: 'className',
|
|
330
|
-
rubricless: true,
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
component.changeRubriclessInstruction('New instruction');
|
|
334
|
-
|
|
335
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
336
|
-
expect.objectContaining({
|
|
337
|
-
rubriclessInstruction: 'New instruction',
|
|
338
|
-
}),
|
|
339
|
-
);
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
describe('edge cases', () => {
|
|
344
|
-
it('handles empty points array', () => {
|
|
345
|
-
const { container } = renderComponent({ points: [], sampleAnswers: [] });
|
|
346
|
-
expect(container).toBeInTheDocument();
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
it('handles maxPoints greater than current max', () => {
|
|
350
|
-
const { onChange } = renderComponent();
|
|
351
|
-
|
|
352
|
-
const component = new RawAuthoring({
|
|
353
|
-
value: { excludeZero: false, points, sampleAnswers },
|
|
354
|
-
onChange,
|
|
355
|
-
classes: {},
|
|
356
|
-
className: 'className',
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
component.changeMaxPoints(10);
|
|
360
|
-
|
|
361
|
-
expect(onChange).toHaveBeenCalled();
|
|
362
|
-
const result = onChange.mock.calls[0][0];
|
|
363
|
-
expect(result.points.length).toBe(11); // 10 + 1 for 0 points
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it('handles config and pluginOpts props', () => {
|
|
367
|
-
const config = { someConfig: true };
|
|
368
|
-
const pluginOpts = { somePlugin: true };
|
|
369
|
-
const { container } = renderComponent({}, { config, pluginOpts });
|
|
370
|
-
expect(container).toBeInTheDocument();
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
});
|