@pie-element/image-cloze-association 6.5.2-next.23 → 6.5.2-next.4

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.
@@ -89,12 +89,11 @@ var ImageDropTarget = /*#__PURE__*/function (_React$Component) {
89
89
  maxResponsePerZone = _this$props.maxResponsePerZone,
90
90
  isOver = _this$props.isOver;
91
91
  var shouldHaveSmallPadding = this.state.shouldHaveSmallPadding;
92
- var isDraggingElement = !!draggingElement.id;
93
- var containerClasses = (0, _classnames["default"])(classes.responseContainer, isOver && classes.isOver, (_cx = {}, (0, _defineProperty2["default"])(_cx, classes.responseContainerDashed, showDashedBorder && !isDraggingElement), (0, _defineProperty2["default"])(_cx, classes.responseContainerActive, isDraggingElement), _cx));
92
+ var containerClasses = (0, _classnames["default"])(classes.responseContainer, isOver && classes.isOver, (_cx = {}, (0, _defineProperty2["default"])(_cx, classes.responseContainerDashed, showDashedBorder && !draggingElement.id), (0, _defineProperty2["default"])(_cx, classes.responseContainerActive, !!draggingElement.id), _cx));
94
93
 
95
94
  var updatedContainerStyle = _objectSpread(_objectSpread({
96
95
  padding: maxResponsePerZone === 1 ? '0' : responseContainerPadding
97
- }, containerStyle), responseAreaFill && !isDraggingElement && {
96
+ }, containerStyle), responseAreaFill && {
98
97
  backgroundColor: responseAreaFill
99
98
  });
100
99
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/image-drop-target.jsx"],"names":["ImageDropTarget","shouldHaveSmallPadding","props","answers","canDrag","classes","containerStyle","draggingElement","onDragAnswerBegin","onDragAnswerEnd","showDashedBorder","responseAreaFill","responseContainerPadding","imageDropTargetPadding","connectDropTarget","answerChoiceTransparency","maxResponsePerZone","isOver","state","isDraggingElement","id","containerClasses","responseContainer","responseContainerDashed","responseContainerActive","updatedContainerStyle","padding","backgroundColor","ref","dropContainerHeight","getBoundingClientRect","height","dropContainerResponsesHeight","setState","length","map","answer","React","Component","propTypes","PropTypes","object","array","bool","isRequired","func","onDrop","string","number","defaultProps","styles","display","flexWrap","dragOverContainer","color","background","pointerEvents","width","position","boxSizing","border","text","Styled","tileSource","hover","monitor","shallow","drop","item","getItem","c","types","response","connect","dropTarget","dragItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;IAEMA,e;;;;;;;;;;;;;;;8FACI;AACNC,MAAAA,sBAAsB,EAAE;AADlB,K;;;;;;WAIR,kBAAS;AAAA;AAAA;;AACP,wBAiBI,KAAKC,KAjBT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,UAEEC,OAFF,eAEEA,OAFF;AAAA,UAGEC,OAHF,eAGEA,OAHF;AAAA,UAIEC,cAJF,eAIEA,cAJF;AAAA,UAKEC,eALF,eAKEA,eALF;AAAA,UAMEC,iBANF,eAMEA,iBANF;AAAA,UAOEC,eAPF,eAOEA,eAPF;AAAA,UAQEC,gBARF,eAQEA,gBARF;AAAA,UASEC,gBATF,eASEA,gBATF;AAAA,UAUEC,wBAVF,eAUEA,wBAVF;AAAA,UAWEC,sBAXF,eAWEA,sBAXF;AAAA,UAaEC,iBAbF,eAaEA,iBAbF;AAAA,UAcEC,wBAdF,eAcEA,wBAdF;AAAA,UAeEC,kBAfF,eAeEA,kBAfF;AAAA,UAgBEC,MAhBF,eAgBEA,MAhBF;AAkBA,UAAQhB,sBAAR,GAAmC,KAAKiB,KAAxC,CAAQjB,sBAAR;AACA,UAAMkB,iBAAiB,GAAG,CAAC,CAACZ,eAAe,CAACa,EAA5C;AAEA,UAAMC,gBAAgB,GAAG,4BAAGhB,OAAO,CAACiB,iBAAX,EAA8BL,MAAM,IAAIZ,OAAO,CAACY,MAAhD,mDACtBZ,OAAO,CAACkB,uBADc,EACYb,gBAAgB,IAAI,CAACS,iBADjC,yCAEtBd,OAAO,CAACmB,uBAFc,EAEYL,iBAFZ,QAAzB;;AAKA,UAAMM,qBAAqB;AACzBC,QAAAA,OAAO,EA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A6BT,UAA7B,EAAyC,UAACU,OAAD,EAAUR,OAAV;AAAA,SAAuB;AAC7EnD,IAAAA,iBAAiB,EAAE2D,OAAO,CAACC,UAAR,EAD0D;AAE7EzD,IAAAA,MAAM,EAAEgD,OAAO,CAAChD,MAAR,EAFqE;AAG7E0D,IAAAA,QAAQ,EAAEV,OAAO,CAACI,OAAR;AAHmE,GAAvB;AAAA,CAAzC,EAIXP,MAJW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { DropTarget } from '@pie-lib/pie-toolbox/drag';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/pie-toolbox/render-ui';\nimport cx from 'classnames';\n\nimport PossibleResponse from './possible-response';\nimport c from './constants';\n\nclass ImageDropTarget extends React.Component {\n state = {\n shouldHaveSmallPadding: false,\n }\n\n render() {\n const {\n answers,\n canDrag,\n classes,\n containerStyle,\n draggingElement,\n onDragAnswerBegin,\n onDragAnswerEnd,\n showDashedBorder,\n responseAreaFill,\n responseContainerPadding,\n imageDropTargetPadding,\n // dnd-related props\n connectDropTarget,\n answerChoiceTransparency,\n maxResponsePerZone,\n isOver,\n } = this.props;\n const { shouldHaveSmallPadding } = this.state;\n const isDraggingElement = !!draggingElement.id;\n\n const containerClasses = cx(classes.responseContainer, isOver && classes.isOver, {\n [classes.responseContainerDashed]: showDashedBorder && !isDraggingElement,\n [classes.responseContainerActive]: isDraggingElement,\n });\n\n const updatedContainerStyle = {\n padding: maxResponsePerZone === 1 ? '0' : responseContainerPadding,\n ...containerStyle,\n ...(responseAreaFill && !isDraggingElement && { backgroundColor: responseAreaFill })\n };\n\n return connectDropTarget(\n <div\n className={containerClasses}\n style={updatedContainerStyle}\n ref={ref => {\n this.dropContainerHeight = ref?.getBoundingClientRect().height;\n\n // If answers area is higher than the initial established response zone,\n // then make sure to use a smaller padding.\n // Only reset the state if needed to prevent maximum callstack exceeded\n if (this.dropContainerHeight < this.dropContainerResponsesHeight && !shouldHaveSmallPadding) {\n this.setState({ shouldHaveSmallPadding: true });\n }\n }}\n >\n {answers.length ? (\n <div\n className={classes.answers}\n ref={ref => {\n this.dropContainerResponsesHeight = ref?.getBoundingClientRect().height;\n }}\n >\n {answers.map((answer) => (\n <PossibleResponse\n key={answer.id}\n data={answer}\n canDrag={canDrag}\n onDragBegin={() => onDragAnswerBegin(answer)}\n onDragEnd={onDragAnswerEnd}\n answerChoiceTransparency={answerChoiceTransparency}\n containerStyle={{\n padding: imageDropTargetPadding\n ? imageDropTargetPadding\n : shouldHaveSmallPadding\n ? '2px'\n : '6px 10px',\n }}\n />\n ))}\n </div>\n ) : null}\n </div>,\n );\n }\n}\n\nImageDropTarget.propTypes = {\n answer: PropTypes.object,\n answers: PropTypes.array,\n canDrag: PropTypes.bool.isRequired,\n classes: PropTypes.object,\n containerStyle: PropTypes.object.isRequired,\n draggingElement: PropTypes.object.isRequired,\n onDragAnswerBegin: PropTypes.func.isRequired,\n onDragAnswerEnd: PropTypes.func.isRequired,\n onDrop: PropTypes.func.isRequired,\n connectDropTarget: PropTypes.func.isRequired,\n showDashedBorder: PropTypes.bool,\n responseAreaFill: PropTypes.string,\n answerChoiceTransparency: PropTypes.bool,\n isOver: PropTypes.bool,\n responseContainerPadding: PropTypes.string,\n imageDropTargetPadding: PropTypes.string,\n maxResponsePerZone: PropTypes.number,\n};\n\nImageDropTarget.defaultProps = {\n answer: {},\n classes: {},\n responseContainerPadding: '10px',\n};\n\nconst styles = () => ({\n answers: {\n display: 'flex',\n flexWrap: 'wrap',\n },\n dragOverContainer: {\n backgroundColor: color.background(),\n pointerEvents: 'none',\n width: 'fit-content',\n },\n responseContainer: {\n position: 'absolute',\n boxSizing: 'border-box'\n },\n responseContainerActive: {\n border: `2px solid ${color.text()}`,\n backgroundColor: 'rgba(230, 242, 252, .8)',\n },\n responseContainerDashed: {\n border: `2px dashed ${color.text()}`,\n },\n isOver: {\n border: '1px solid rgb(158, 158, 158)',\n backgroundColor: 'rgb(224, 224, 224)',\n }\n});\n\nconst Styled = withStyles(styles)(ImageDropTarget);\n\nconst tileSource = {\n hover(props, monitor) {\n monitor.isOver({ shallow: true });\n },\n drop(props, monitor) {\n const item = monitor.getItem();\n props.onDrop(item);\n },\n};\n\nexport default DropTarget(c.types.response, tileSource, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n dragItem: monitor.getItem(),\n}))(Styled);\n"],"file":"image-drop-target.js"}
1
+ {"version":3,"sources":["../src/image-drop-target.jsx"],"names":["ImageDropTarget","shouldHaveSmallPadding","props","answers","canDrag","classes","containerStyle","draggingElement","onDragAnswerBegin","onDragAnswerEnd","showDashedBorder","responseAreaFill","responseContainerPadding","imageDropTargetPadding","connectDropTarget","answerChoiceTransparency","maxResponsePerZone","isOver","state","containerClasses","responseContainer","responseContainerDashed","id","responseContainerActive","updatedContainerStyle","padding","backgroundColor","ref","dropContainerHeight","getBoundingClientRect","height","dropContainerResponsesHeight","setState","length","map","answer","React","Component","propTypes","PropTypes","object","array","bool","isRequired","func","onDrop","string","number","defaultProps","styles","display","flexWrap","dragOverContainer","color","background","pointerEvents","width","position","boxSizing","border","text","Styled","tileSource","hover","monitor","shallow","drop","item","getItem","c","types","response","connect","dropTarget","dragItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;IAEMA,e;;;;;;;;;;;;;;;8FACI;AACNC,MAAAA,sBAAsB,EAAE;AADlB,K;;;;;;WAIR,kBAAS;AAAA;AAAA;;AACP,wBAiBI,KAAKC,KAjBT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,UAEEC,OAFF,eAEEA,OAFF;AAAA,UAGEC,OAHF,eAGEA,OAHF;AAAA,UAIEC,cAJF,eAIEA,cAJF;AAAA,UAKEC,eALF,eAKEA,eALF;AAAA,UAMEC,iBANF,eAMEA,iBANF;AAAA,UAOEC,eAPF,eAOEA,eAPF;AAAA,UAQEC,gBARF,e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BL;AAqBpB3C,IAAAA,MAAM,EAAE;AACN0C,MAAAA,MAAM,EAAE,8BADF;AAENjC,MAAAA,eAAe,EAAE;AAFX;AArBY,GAAP;AAAA,CAAf;;AA2BA,IAAMmC,MAAM,GAAG,wBAAWZ,MAAX,EAAmBjD,eAAnB,CAAf;AAEA,IAAM8D,UAAU,GAAG;AACjBC,EAAAA,KADiB,iBACX7D,KADW,EACJ8D,OADI,EACK;AACpBA,IAAAA,OAAO,CAAC/C,MAAR,CAAe;AAAEgD,MAAAA,OAAO,EAAE;AAAX,KAAf;AACD,GAHgB;AAIjBC,EAAAA,IAJiB,gBAIZhE,KAJY,EAIL8D,OAJK,EAII;AACnB,QAAMG,IAAI,GAAGH,OAAO,CAACI,OAAR,EAAb;AACAlE,IAAAA,KAAK,CAAC2C,MAAN,CAAasB,IAAb;AACD;AAPgB,CAAnB;;eAUe,sBAAWE,sBAAEC,KAAF,CAAQC,QAAnB,EAA6BT,UAA7B,EAAyC,UAACU,OAAD,EAAUR,OAAV;AAAA,SAAuB;AAC7ElD,IAAAA,iBAAiB,EAAE0D,OAAO,CAACC,UAAR,EAD0D;AAE7ExD,IAAAA,MAAM,EAAE+C,OAAO,CAAC/C,MAAR,EAFqE;AAG7EyD,IAAAA,QAAQ,EAAEV,OAAO,CAACI,OAAR;AAHmE,GAAvB;AAAA,CAAzC,EAIXP,MAJW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { DropTarget } from '@pie-lib/pie-toolbox/drag';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/pie-toolbox/render-ui';\nimport cx from 'classnames';\n\nimport PossibleResponse from './possible-response';\nimport c from './constants';\n\nclass ImageDropTarget extends React.Component {\n state = {\n shouldHaveSmallPadding: false,\n }\n\n render() {\n const {\n answers,\n canDrag,\n classes,\n containerStyle,\n draggingElement,\n onDragAnswerBegin,\n onDragAnswerEnd,\n showDashedBorder,\n responseAreaFill,\n responseContainerPadding,\n imageDropTargetPadding,\n // dnd-related props\n connectDropTarget,\n answerChoiceTransparency,\n maxResponsePerZone,\n isOver,\n } = this.props;\n const { shouldHaveSmallPadding } = this.state;\n\n const containerClasses = cx(classes.responseContainer, isOver && classes.isOver, {\n [classes.responseContainerDashed]: showDashedBorder && !draggingElement.id,\n [classes.responseContainerActive]: !!draggingElement.id,\n });\n\n const updatedContainerStyle = {\n padding: maxResponsePerZone === 1 ? '0' : responseContainerPadding,\n ...containerStyle,\n ...(responseAreaFill && { backgroundColor: responseAreaFill })\n };\n\n return connectDropTarget(\n <div\n className={containerClasses}\n style={updatedContainerStyle}\n ref={ref => {\n this.dropContainerHeight = ref?.getBoundingClientRect().height;\n\n // If answers area is higher than the initial established response zone,\n // then make sure to use a smaller padding.\n // Only reset the state if needed to prevent maximum callstack exceeded\n if (this.dropContainerHeight < this.dropContainerResponsesHeight && !shouldHaveSmallPadding) {\n this.setState({ shouldHaveSmallPadding: true });\n }\n }}\n >\n {answers.length ? (\n <div\n className={classes.answers}\n ref={ref => {\n this.dropContainerResponsesHeight = ref?.getBoundingClientRect().height;\n }}\n >\n {answers.map((answer) => (\n <PossibleResponse\n key={answer.id}\n data={answer}\n canDrag={canDrag}\n onDragBegin={() => onDragAnswerBegin(answer)}\n onDragEnd={onDragAnswerEnd}\n answerChoiceTransparency={answerChoiceTransparency}\n containerStyle={{\n padding: imageDropTargetPadding\n ? imageDropTargetPadding\n : shouldHaveSmallPadding\n ? '2px'\n : '6px 10px',\n }}\n />\n ))}\n </div>\n ) : null}\n </div>,\n );\n }\n}\n\nImageDropTarget.propTypes = {\n answer: PropTypes.object,\n answers: PropTypes.array,\n canDrag: PropTypes.bool.isRequired,\n classes: PropTypes.object,\n containerStyle: PropTypes.object.isRequired,\n draggingElement: PropTypes.object.isRequired,\n onDragAnswerBegin: PropTypes.func.isRequired,\n onDragAnswerEnd: PropTypes.func.isRequired,\n onDrop: PropTypes.func.isRequired,\n connectDropTarget: PropTypes.func.isRequired,\n showDashedBorder: PropTypes.bool,\n responseAreaFill: PropTypes.string,\n answerChoiceTransparency: PropTypes.bool,\n isOver: PropTypes.bool,\n responseContainerPadding: PropTypes.string,\n imageDropTargetPadding: PropTypes.string,\n maxResponsePerZone: PropTypes.number,\n};\n\nImageDropTarget.defaultProps = {\n answer: {},\n classes: {},\n responseContainerPadding: '10px',\n};\n\nconst styles = () => ({\n answers: {\n display: 'flex',\n flexWrap: 'wrap',\n },\n dragOverContainer: {\n backgroundColor: color.background(),\n pointerEvents: 'none',\n width: 'fit-content',\n },\n responseContainer: {\n position: 'absolute',\n boxSizing: 'border-box'\n },\n responseContainerActive: {\n border: `2px solid ${color.text()}`,\n backgroundColor: 'rgba(230, 242, 252, .8)',\n },\n responseContainerDashed: {\n border: `2px dashed ${color.text()}`,\n },\n isOver: {\n border: '1px solid rgb(158, 158, 158)',\n backgroundColor: 'rgb(224, 224, 224)',\n }\n});\n\nconst Styled = withStyles(styles)(ImageDropTarget);\n\nconst tileSource = {\n hover(props, monitor) {\n monitor.isOver({ shallow: true });\n },\n drop(props, monitor) {\n const item = monitor.getItem();\n props.onDrop(item);\n },\n};\n\nexport default DropTarget(c.types.response, tileSource, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n dragItem: monitor.getItem(),\n}))(Styled);\n"],"file":"image-drop-target.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/image-cloze-association",
3
- "version": "6.5.2-next.23+61d1667c0",
3
+ "version": "6.5.2-next.4+dba7b2f5e",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "author": "pie framework developers",
21
21
  "license": "ISC",
22
- "gitHead": "61d1667c0fef5739f3ff88828f52468f8bdcf7e2",
22
+ "gitHead": "dba7b2f5e68bd1d212e03ad1e4e574c55f58b150",
23
23
  "scripts": {
24
24
  "postpublish": "../../scripts/postpublish"
25
25
  },
@@ -33,17 +33,16 @@ class ImageDropTarget extends React.Component {
33
33
  isOver,
34
34
  } = this.props;
35
35
  const { shouldHaveSmallPadding } = this.state;
36
- const isDraggingElement = !!draggingElement.id;
37
36
 
38
37
  const containerClasses = cx(classes.responseContainer, isOver && classes.isOver, {
39
- [classes.responseContainerDashed]: showDashedBorder && !isDraggingElement,
40
- [classes.responseContainerActive]: isDraggingElement,
38
+ [classes.responseContainerDashed]: showDashedBorder && !draggingElement.id,
39
+ [classes.responseContainerActive]: !!draggingElement.id,
41
40
  });
42
41
 
43
42
  const updatedContainerStyle = {
44
43
  padding: maxResponsePerZone === 1 ? '0' : responseContainerPadding,
45
44
  ...containerStyle,
46
- ...(responseAreaFill && !isDraggingElement && { backgroundColor: responseAreaFill })
45
+ ...(responseAreaFill && { backgroundColor: responseAreaFill })
47
46
  };
48
47
 
49
48
  return connectDropTarget(
@@ -1,163 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`image-cloze-association renders snapshot 1`] = `
4
- <WithStyles(UiLayout)>
5
- <WithStyles(PreviewPrompt)
6
- className="prompt"
7
- />
8
- <WithStyles(PreviewPrompt) />
9
- <WithStyles(CorrectAnswerToggle)
10
- onToggle={[Function]}
11
- show={false}
12
- toggled={false}
13
- />
14
- <WithStyles(InteractiveSection)
15
- uiStyle={Object {}}
16
- >
17
- <WithStyles(ImageContainer)
18
- answers={Array []}
19
- canDrag={true}
20
- draggingElement={
21
- Object {
22
- "id": "",
23
- "value": "",
24
- }
25
- }
26
- maxResponsePerZone={1}
27
- onAnswerSelect={[Function]}
28
- onDragAnswerBegin={[Function]}
29
- onDragAnswerEnd={[Function]}
30
- responseContainers={Array []}
31
- />
32
- <WithStyles(PossibleResponses)
33
- canDrag={true}
34
- customStyle={
35
- Object {
36
- "minWidth": "fit-content",
37
- }
38
- }
39
- data={Array []}
40
- isVertical={false}
41
- onAnswerRemove={[Function]}
42
- onDragBegin={[Function]}
43
- onDragEnd={[Function]}
44
- />
45
- </WithStyles(InteractiveSection)>
46
- </WithStyles(UiLayout)>
47
- `;
48
-
49
- exports[`image-cloze-association renders snapshot with rationale 1`] = `
50
- <WithStyles(UiLayout)>
51
- <WithStyles(PreviewPrompt)
52
- className="prompt"
53
- />
54
- <WithStyles(PreviewPrompt) />
55
- <WithStyles(CorrectAnswerToggle)
56
- onToggle={[Function]}
57
- show={false}
58
- toggled={false}
59
- />
60
- <WithStyles(InteractiveSection)
61
- uiStyle={Object {}}
62
- >
63
- <WithStyles(ImageContainer)
64
- answers={Array []}
65
- canDrag={true}
66
- draggingElement={
67
- Object {
68
- "id": "",
69
- "value": "",
70
- }
71
- }
72
- maxResponsePerZone={1}
73
- onAnswerSelect={[Function]}
74
- onDragAnswerBegin={[Function]}
75
- onDragAnswerEnd={[Function]}
76
- responseContainers={Array []}
77
- />
78
- <WithStyles(PossibleResponses)
79
- canDrag={true}
80
- customStyle={
81
- Object {
82
- "minWidth": "fit-content",
83
- }
84
- }
85
- data={Array []}
86
- isVertical={false}
87
- onAnswerRemove={[Function]}
88
- onDragBegin={[Function]}
89
- onDragEnd={[Function]}
90
- />
91
- </WithStyles(InteractiveSection)>
92
- <WithStyles(Collapsible)
93
- labels={
94
- Object {
95
- "hidden": "Show Rationale",
96
- "visible": "Hide Rationale",
97
- }
98
- }
99
- >
100
- <WithStyles(PreviewPrompt)
101
- prompt="This is rationale"
102
- />
103
- </WithStyles(Collapsible)>
104
- </WithStyles(UiLayout)>
105
- `;
106
-
107
- exports[`image-cloze-association renders snapshot with teacherInstructions 1`] = `
108
- <WithStyles(UiLayout)>
109
- <WithStyles(Collapsible)
110
- labels={
111
- Object {
112
- "hidden": "Show Teacher Instructions",
113
- "visible": "Hide Teacher Instructions",
114
- }
115
- }
116
- >
117
- <WithStyles(PreviewPrompt)
118
- prompt="These are teacher instructions"
119
- />
120
- </WithStyles(Collapsible)>
121
- <WithStyles(PreviewPrompt)
122
- className="prompt"
123
- />
124
- <WithStyles(PreviewPrompt) />
125
- <WithStyles(CorrectAnswerToggle)
126
- onToggle={[Function]}
127
- show={false}
128
- toggled={false}
129
- />
130
- <WithStyles(InteractiveSection)
131
- uiStyle={Object {}}
132
- >
133
- <WithStyles(ImageContainer)
134
- answers={Array []}
135
- canDrag={true}
136
- draggingElement={
137
- Object {
138
- "id": "",
139
- "value": "",
140
- }
141
- }
142
- maxResponsePerZone={1}
143
- onAnswerSelect={[Function]}
144
- onDragAnswerBegin={[Function]}
145
- onDragAnswerEnd={[Function]}
146
- responseContainers={Array []}
147
- />
148
- <WithStyles(PossibleResponses)
149
- canDrag={true}
150
- customStyle={
151
- Object {
152
- "minWidth": "fit-content",
153
- }
154
- }
155
- data={Array []}
156
- isVertical={false}
157
- onAnswerRemove={[Function]}
158
- onDragBegin={[Function]}
159
- onDragEnd={[Function]}
160
- />
161
- </WithStyles(InteractiveSection)>
162
- </WithStyles(UiLayout)>
163
- `;
@@ -1,82 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';
4
- import ImageClozeAssociation from '../index';
5
- import { ImageClozeAssociationComponent } from '../root';
6
-
7
- jest.mock('@pie-lib/pie-toolbox/math-rendering-accessible', () => ({ renderMath: jest.fn() }));
8
-
9
- describe('image-cloze-association', () => {
10
- describe('renders', () => {
11
- let wrapper = (props) => {
12
- let defaultProps = {
13
- model: { ...props },
14
- session: {},
15
- classes: {},
16
- };
17
-
18
- return shallow(<ImageClozeAssociationComponent {...defaultProps} />);
19
- };
20
-
21
- it('snapshot', () => {
22
- const w = wrapper();
23
- expect(w).toMatchSnapshot();
24
- });
25
-
26
- it('snapshot with rationale', () => {
27
- const w = wrapper({ rationale: 'This is rationale' });
28
- expect(w).toMatchSnapshot();
29
- });
30
-
31
- it('snapshot with teacherInstructions', () => {
32
- const w = wrapper({ teacherInstructions: 'These are teacher instructions' });
33
- expect(w).toMatchSnapshot();
34
- });
35
- });
36
-
37
- describe('events', () => {
38
- describe('model', () => {
39
- it('dispatches model set event', () => {
40
- const el = new ImageClozeAssociation();
41
- el.tagName = 'ica-el';
42
- el.model = {};
43
- expect(el.dispatchEvent).toBeCalledWith(new ModelSetEvent('ica-el', false, true));
44
- });
45
- });
46
-
47
- describe('updateAnswer', () => {
48
- it('dispatches session changed event - add answer', () => {
49
- const el = new ImageClozeAssociation();
50
- el.tagName = 'ica-el';
51
- el.session = { answers: [] };
52
- el.updateAnswer([{ id: '1', containerIndex: 0, value: '' }]);
53
- expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('ica-el', true));
54
- });
55
-
56
- it('dispatches session changed event - remove answer', () => {
57
- const el = new ImageClozeAssociation();
58
- el.tagName = 'ica-el';
59
- el.session = { answers: [{ id: '1', containerIndex: 0, value: '' }] };
60
- el.updateAnswer([]);
61
- expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('ica-el', false));
62
- });
63
-
64
- it('dispatches session changed event - add/remove answer', () => {
65
- const el = new ImageClozeAssociation();
66
- el.tagName = 'ica-el';
67
- el.session = { answers: [{ id: '1', containerIndex: 0, value: '' }] };
68
- el.updateAnswer([
69
- { id: '1', containerIndex: 0, value: '' },
70
- { id: '2', containerIndex: 1, value: '' },
71
- ]);
72
- expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('ica-el', true));
73
-
74
- el.updateAnswer([{ id: '2', containerIndex: 1, value: '' }]);
75
- expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('ica-el', true));
76
-
77
- el.updateAnswer([]);
78
- expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('ica-el', false));
79
- });
80
- });
81
- });
82
- });