@khanacademy/perseus-editor 4.1.4 → 4.1.6

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.
Files changed (175) hide show
  1. package/dist/es/index.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/package.json +9 -6
  4. package/.babelrc.js +0 -8
  5. package/.eslintrc.js +0 -12
  6. package/CHANGELOG.md +0 -1146
  7. package/src/README.md +0 -7
  8. package/src/__stories__/editor-page.stories.tsx +0 -65
  9. package/src/__stories__/editor.stories.tsx +0 -134
  10. package/src/__stories__/item-editor.stories.tsx +0 -41
  11. package/src/__stories__/tex-error-view.stories.tsx +0 -26
  12. package/src/__testdata__/input-number.testdata.ts +0 -27
  13. package/src/__tests__/editor.test.tsx +0 -142
  14. package/src/__tests__/hint-editor.test.tsx +0 -83
  15. package/src/__tests__/i18n.test.ts +0 -501
  16. package/src/__tests__/integration.test.ts +0 -5
  17. package/src/__tests__/item-extras-editor.test.tsx +0 -85
  18. package/src/__tests__/traversal.test.ts +0 -377
  19. package/src/all-editors.test.ts +0 -16
  20. package/src/all-editors.ts +0 -83
  21. package/src/all-widgets.ts +0 -7
  22. package/src/article-editor.tsx +0 -438
  23. package/src/components/__stories__/blur-input.stories.tsx +0 -22
  24. package/src/components/__stories__/section-control-button.stories.tsx +0 -26
  25. package/src/components/__tests__/blur-input.test.tsx +0 -67
  26. package/src/components/blur-input.tsx +0 -69
  27. package/src/components/checkbox.tsx +0 -194
  28. package/src/components/device-framer.tsx +0 -90
  29. package/src/components/drag-target.tsx +0 -87
  30. package/src/components/dropdown-option.tsx +0 -311
  31. package/src/components/form-wrapped-text-field.tsx +0 -245
  32. package/src/components/graph-points-count-selector.tsx +0 -31
  33. package/src/components/graph-settings.tsx +0 -627
  34. package/src/components/graph-type-selector.tsx +0 -31
  35. package/src/components/hover-behavior.ts +0 -177
  36. package/src/components/json-editor.tsx +0 -121
  37. package/src/components/link.ts +0 -173
  38. package/src/components/section-control-button.tsx +0 -53
  39. package/src/components/segment-count-selector.tsx +0 -27
  40. package/src/components/simple-button.tsx +0 -85
  41. package/src/components/sortable.tsx +0 -187
  42. package/src/components/util.ts +0 -38
  43. package/src/components/viewport-resizer.tsx +0 -72
  44. package/src/components/widget-editor.tsx +0 -222
  45. package/src/components/widget-select.tsx +0 -48
  46. package/src/diffs/__stories__/perseus-diff-wrapper.tsx +0 -11
  47. package/src/diffs/__stories__/structured-item-diff.stories.tsx +0 -855
  48. package/src/diffs/__stories__/tags-diff.stories.tsx +0 -36
  49. package/src/diffs/__stories__/text-diff.stories.tsx +0 -35
  50. package/src/diffs/__tests__/split-diff.test.ts +0 -33
  51. package/src/diffs/__tests__/string-array-diff.test.ts +0 -73
  52. package/src/diffs/__tests__/structured-item-diff.test.ts +0 -433
  53. package/src/diffs/__tests__/widget-diff-performer.test.ts +0 -43
  54. package/src/diffs/article-diff.tsx +0 -69
  55. package/src/diffs/item-diff.tsx +0 -76
  56. package/src/diffs/renderer-diff.tsx +0 -137
  57. package/src/diffs/split-diff.ts +0 -31
  58. package/src/diffs/string-array-diff.ts +0 -74
  59. package/src/diffs/structured-item-diff.tsx +0 -275
  60. package/src/diffs/tags-diff.tsx +0 -49
  61. package/src/diffs/text-diff.tsx +0 -193
  62. package/src/diffs/widget-diff-performer.ts +0 -69
  63. package/src/diffs/widget-diff.tsx +0 -290
  64. package/src/editor-page.tsx +0 -325
  65. package/src/editor.tsx +0 -1099
  66. package/src/hint-editor.tsx +0 -469
  67. package/src/i18n.ts +0 -140
  68. package/src/iframe-content-renderer.tsx +0 -188
  69. package/src/index.ts +0 -30
  70. package/src/item-editor.tsx +0 -158
  71. package/src/item-extras-editor.tsx +0 -230
  72. package/src/katex-mhchem/index.js +0 -73
  73. package/src/katex-mhchem/parser.js +0 -2659
  74. package/src/multirenderer-editor.tsx +0 -1061
  75. package/src/stateful-article-editor.tsx +0 -173
  76. package/src/stateful-editor-page.tsx +0 -88
  77. package/src/styles/perseus-editor.less +0 -1321
  78. package/src/testing-widgets.ts +0 -11
  79. package/src/tex-error-view.tsx +0 -90
  80. package/src/util/points.test.ts +0 -24
  81. package/src/util/points.ts +0 -13
  82. package/src/util/register-all-widgets-and-editors-for-testing.test.ts +0 -17
  83. package/src/util/register-all-widgets-and-editors-for-testing.ts +0 -17
  84. package/src/version.ts +0 -10
  85. package/src/widgets/__stories__/categorizer-editor.stories.tsx +0 -24
  86. package/src/widgets/__stories__/definition-editor.stories.tsx +0 -18
  87. package/src/widgets/__stories__/dropdown-editor.stories.tsx +0 -18
  88. package/src/widgets/__stories__/explanation-editor.stories.tsx +0 -18
  89. package/src/widgets/__stories__/expression-editor.stories.tsx +0 -122
  90. package/src/widgets/__stories__/image-editor.stories.tsx +0 -72
  91. package/src/widgets/__stories__/input-number-editor.stories.tsx +0 -18
  92. package/src/widgets/__stories__/interaction-editor.stories.tsx +0 -37
  93. package/src/widgets/__stories__/label-image-editor.stories.tsx +0 -99
  94. package/src/widgets/__stories__/matcher-editor.stories.tsx +0 -18
  95. package/src/widgets/__stories__/number-line-editor.stories.tsx +0 -18
  96. package/src/widgets/__stories__/numeric-input-editor.stories.tsx +0 -18
  97. package/src/widgets/__stories__/radio-editor.stories.tsx +0 -116
  98. package/src/widgets/__stories__/sorter-editor.stories.tsx +0 -18
  99. package/src/widgets/__tests__/categorizer-editor.test.tsx +0 -51
  100. package/src/widgets/__tests__/definition-editor.test.tsx +0 -41
  101. package/src/widgets/__tests__/dropdown-editor.test.tsx +0 -57
  102. package/src/widgets/__tests__/explanation-editor.test.tsx +0 -59
  103. package/src/widgets/__tests__/expression-editor.test.tsx +0 -403
  104. package/src/widgets/__tests__/input-number-editor.test.tsx +0 -128
  105. package/src/widgets/__tests__/matcher-editor.test.tsx +0 -47
  106. package/src/widgets/__tests__/number-line-editor.test.tsx +0 -144
  107. package/src/widgets/__tests__/numeric-input-editor.test.tsx +0 -177
  108. package/src/widgets/__tests__/radio-editor.test.tsx +0 -118
  109. package/src/widgets/__tests__/sorter-editor.test.tsx +0 -55
  110. package/src/widgets/categorizer-editor.tsx +0 -104
  111. package/src/widgets/cs-program-editor.tsx +0 -256
  112. package/src/widgets/definition-editor.tsx +0 -77
  113. package/src/widgets/deprecated-standin-editor.tsx +0 -29
  114. package/src/widgets/dropdown-editor.tsx +0 -211
  115. package/src/widgets/example-graphie-widget-editor.tsx +0 -70
  116. package/src/widgets/example-graphie-widget.tsx +0 -172
  117. package/src/widgets/example-widget-editor.tsx +0 -62
  118. package/src/widgets/example-widget.tsx +0 -154
  119. package/src/widgets/explanation-editor.tsx +0 -92
  120. package/src/widgets/expression-editor.tsx +0 -557
  121. package/src/widgets/graded-group-editor.tsx +0 -161
  122. package/src/widgets/graded-group-set-editor.tsx +0 -104
  123. package/src/widgets/grapher-editor.tsx +0 -155
  124. package/src/widgets/group-editor.tsx +0 -83
  125. package/src/widgets/iframe-editor.tsx +0 -202
  126. package/src/widgets/image-editor.tsx +0 -367
  127. package/src/widgets/input-number-editor.tsx +0 -288
  128. package/src/widgets/interaction-editor/constraint-editor.tsx +0 -134
  129. package/src/widgets/interaction-editor/function-editor.tsx +0 -108
  130. package/src/widgets/interaction-editor/index.ts +0 -3
  131. package/src/widgets/interaction-editor/interaction-editor.tsx +0 -749
  132. package/src/widgets/interaction-editor/label-editor.tsx +0 -87
  133. package/src/widgets/interaction-editor/line-editor.tsx +0 -125
  134. package/src/widgets/interaction-editor/mathquill-input.tsx +0 -81
  135. package/src/widgets/interaction-editor/movable-line-editor.tsx +0 -121
  136. package/src/widgets/interaction-editor/movable-point-editor.tsx +0 -89
  137. package/src/widgets/interaction-editor/parametric-editor.tsx +0 -117
  138. package/src/widgets/interaction-editor/point-editor.tsx +0 -72
  139. package/src/widgets/interaction-editor/rectangle-editor.tsx +0 -96
  140. package/src/widgets/interactive-graph-editor.tsx +0 -571
  141. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +0 -82
  142. package/src/widgets/label-image/__stories__/behavior.stories.tsx +0 -31
  143. package/src/widgets/label-image/__stories__/marker.stories.tsx +0 -75
  144. package/src/widgets/label-image/__stories__/question-markers.stories.tsx +0 -107
  145. package/src/widgets/label-image/__stories__/select-image.stories.tsx +0 -59
  146. package/src/widgets/label-image/answer-choices.tsx +0 -231
  147. package/src/widgets/label-image/behavior.tsx +0 -122
  148. package/src/widgets/label-image/marker.tsx +0 -290
  149. package/src/widgets/label-image/question-markers.tsx +0 -176
  150. package/src/widgets/label-image/select-image.tsx +0 -81
  151. package/src/widgets/label-image-editor.tsx +0 -252
  152. package/src/widgets/lights-puzzle-editor.tsx +0 -278
  153. package/src/widgets/matcher-editor.tsx +0 -149
  154. package/src/widgets/matrix-editor.tsx +0 -156
  155. package/src/widgets/measurer-editor.tsx +0 -253
  156. package/src/widgets/molecule-editor.tsx +0 -64
  157. package/src/widgets/number-line-editor.tsx +0 -512
  158. package/src/widgets/numeric-input-editor.tsx +0 -536
  159. package/src/widgets/orderer-editor.tsx +0 -172
  160. package/src/widgets/passage-editor.tsx +0 -117
  161. package/src/widgets/passage-ref-editor.tsx +0 -80
  162. package/src/widgets/passage-ref-target-editor.tsx +0 -49
  163. package/src/widgets/plotter-editor.tsx +0 -542
  164. package/src/widgets/radio/editor.tsx +0 -398
  165. package/src/widgets/reaction-diagram-editor.tsx +0 -131
  166. package/src/widgets/sequence-editor.tsx +0 -205
  167. package/src/widgets/simple-markdown-tester-editor.tsx +0 -86
  168. package/src/widgets/simple-markdown-tester.tsx +0 -92
  169. package/src/widgets/simulator-editor.tsx +0 -146
  170. package/src/widgets/sorter-editor.tsx +0 -103
  171. package/src/widgets/table-editor.tsx +0 -164
  172. package/src/widgets/unit-editor.tsx +0 -299
  173. package/src/widgets/video-editor.tsx +0 -73
  174. package/tsconfig-build.json +0 -22
  175. package/tsconfig-build.tsbuildinfo +0 -1
@@ -1,501 +0,0 @@
1
- import {Dependencies} from "@khanacademy/perseus";
2
- import _ from "underscore";
3
-
4
- import {testDependencies} from "../../../../testing/test-dependencies";
5
- import i18n from "../i18n";
6
- import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing";
7
-
8
- const exerciseImagesEverywhere = {
9
- question: {
10
- content:
11
- "![question-a](question-a)\n\n![question-b](question-b)\n\n[[☃ categorizer 1]]\n\n[[☃ group 1]]\n\n[[☃ image 1]]\n\n[[☃ matcher 1]]\n\n[[☃ matrix 1]]\n\n[[☃ orderer 1]]\n\n[[☃ passage 1]]\n\n[[☃ radio 1]]\n\n[[☃ sorter 1]]\n\n[[☃ table 1]]\n\n[[☃ grapher 1]]\n\n[[☃ interactive-graph 1]]\n\n[[☃ measurer 1]]\n\n[[☃ plotter 1]]",
12
- images: {},
13
- widgets: {
14
- "categorizer 1": {
15
- type: "categorizer",
16
- graded: true,
17
- options: {
18
- items: [
19
- "![category-item-a](category-item-a)",
20
- "![category-item-b](category-item-b)",
21
- ],
22
- categories: [
23
- "![category-category-a](category-category-a)",
24
- "![category-category-b](category-category-b)",
25
- ],
26
- values: [],
27
- randomizeItems: false,
28
- },
29
- version: {major: 0, minor: 0},
30
- },
31
- "group 1": {
32
- type: "group",
33
- graded: true,
34
- options: {
35
- content:
36
- "![group-a](group-a)\n\n![group-b](group-b)\n\n[[☃ image 1]]",
37
- images: {},
38
- widgets: {
39
- "image 1": {
40
- type: "image",
41
- graded: true,
42
- options: {
43
- title: "![group-image-title-a](group-image-title-a) ![group-image-title-b](group-image-title-b)",
44
- range: [
45
- [0, 10],
46
- [0, 10],
47
- ],
48
- box: [0, 0],
49
- backgroundImage: {
50
- url: "group-image-a",
51
- width: 0,
52
- height: 0,
53
- },
54
- labels: [],
55
- alt: "",
56
- caption:
57
- "![group-image-caption-a](group-image-caption-a) ![group-image-caption-b](group-image-caption-b)",
58
- },
59
- version: {major: 0, minor: 0},
60
- },
61
- },
62
- },
63
- version: {major: 0, minor: 0},
64
- },
65
- "image 1": {
66
- type: "image",
67
- graded: true,
68
- options: {
69
- title: "![image-title-a](image-title-a) ![image-title-b](image-title-b)",
70
- range: [
71
- [0, 10],
72
- [0, 10],
73
- ],
74
- box: [0, 0],
75
- backgroundImage: {url: "image-a", width: 0, height: 0},
76
- labels: [],
77
- alt: "",
78
- caption:
79
- "![image-caption-a](image-caption-a) ![image-caption-b](image-caption-b)",
80
- },
81
- version: {major: 0, minor: 0},
82
- },
83
- "matcher 1": {
84
- type: "matcher",
85
- graded: true,
86
- options: {
87
- left: [
88
- "![matcher-left-a](matcher-left-a)",
89
- "![matcher-left-b](matcher-left-b)",
90
- ],
91
- right: [
92
- "![matcher-right-a](matcher-right-a)",
93
- "![matcher-right-b](matcher-right-b)",
94
- ],
95
- labels: [
96
- "![matcher-label-a](matcher-label-a)",
97
- "![matcher-label-b](matcher-label-b)",
98
- ],
99
- orderMatters: false,
100
- padding: true,
101
- },
102
- version: {major: 0, minor: 0},
103
- },
104
- "matrix 1": {
105
- type: "matrix",
106
- graded: true,
107
- options: {
108
- matrixBoardSize: [3, 3],
109
- answers: [[]],
110
- prefix: "![matrix-prefix-a](matrix-prefix-a) ![matrix-prefix-b](matrix-prefix-b)",
111
- suffix: "![matrix-suffix-a](matrix-suffix-a) ![matrix-suffix-b](matrix-suffix-b)",
112
- cursorPosition: [0, 0],
113
- },
114
- version: {major: 0, minor: 0},
115
- },
116
- "orderer 1": {
117
- type: "orderer",
118
- graded: true,
119
- options: {
120
- options: [
121
- {content: "![orderer-correct-a](orderer-correct-a)"},
122
- {content: "![orderer-correct-b](orderer-correct-b)"},
123
- {content: "![orderer-other-a](orderer-other-a)"},
124
- {content: "![orderer-other-b](orderer-other-b)"},
125
- ],
126
- correctOptions: [
127
- {content: "![orderer-correct-a](orderer-correct-a)"},
128
- {content: "![orderer-correct-b](orderer-correct-b)"},
129
- ],
130
- otherOptions: [
131
- {content: "![orderer-other-a](orderer-other-a)"},
132
- {content: "![orderer-other-b](orderer-other-b)"},
133
- ],
134
- height: "normal",
135
- layout: "horizontal",
136
- },
137
- version: {major: 0, minor: 0},
138
- },
139
- "passage 1": {
140
- type: "passage",
141
- graded: true,
142
- options: {
143
- passageTitle:
144
- "![passage-title-a](passage-title-a) ![passage-title-b](passage-title-b)",
145
- passageText: "",
146
- footnotes: "",
147
- showLineNumbers: true,
148
- },
149
- version: {major: 0, minor: 0},
150
- },
151
- "radio 1": {
152
- type: "radio",
153
- graded: true,
154
- options: {
155
- choices: [
156
- {
157
- content:
158
- "![radio-choice1-a](radio-choice1-a) ![radio-choice1-b](radio-choice1-b)",
159
- },
160
- {
161
- content:
162
- "![radio-choice2-a](radio-choice2-a) ![radio-choice2-b](radio-choice2-b)",
163
- },
164
- ],
165
- randomize: false,
166
- multipleSelect: false,
167
- displayCount: null,
168
- hasNoneOfTheAbove: false,
169
- onePerLine: true,
170
- deselectEnabled: false,
171
- },
172
- version: {major: 1, minor: 0},
173
- },
174
- "sorter 1": {
175
- type: "sorter",
176
- graded: true,
177
- options: {
178
- correct: [
179
- "![sorter-correct-a](sorter-correct-a)",
180
- "![sorter-correct-b](sorter-correct-b)",
181
- "![sorter-correct-c](sorter-correct-c)",
182
- ],
183
- layout: "horizontal",
184
- padding: true,
185
- },
186
- version: {major: 0, minor: 0},
187
- },
188
- "table 1": {
189
- type: "table",
190
- graded: true,
191
- options: {
192
- headers: [
193
- "![table-header-a](table-header-a)",
194
- "![table-header-b](table-header-b)",
195
- "![table-header-c](table-header-c)",
196
- ],
197
- rows: 4,
198
- columns: 3,
199
- answers: [
200
- ["", "", ""],
201
- ["", "", ""],
202
- ["", "", ""],
203
- ["", "", ""],
204
- ],
205
- },
206
- version: {major: 0, minor: 0},
207
- },
208
- "grapher 1": {
209
- type: "grapher",
210
- graded: true,
211
- options: {
212
- correct: {type: "linear", coords: null, asymptote: null},
213
- availableTypes: ["linear"],
214
- graph: {
215
- editableSettings: ["graph", "snap", "image"],
216
- range: [
217
- [-10, 10],
218
- [-10, 10],
219
- ],
220
- labels: ["x", "y"],
221
- step: [1, 1],
222
- gridStep: [1, 1],
223
- snapStep: [1, 1],
224
- valid: true,
225
- backgroundImage: {
226
- url: "grapher-a",
227
- width: 32,
228
- height: 32,
229
- },
230
- markings: "graph",
231
- rulerLabel: "",
232
- rulerTicks: 10,
233
- showProtractor: false,
234
- showRuler: false,
235
- },
236
- },
237
- version: {major: 0, minor: 0},
238
- },
239
- "interactive-graph 1": {
240
- type: "interactive-graph",
241
- graded: true,
242
- options: {
243
- step: [1, 1],
244
- backgroundImage: {
245
- url: "interactive-graph-a",
246
- width: 32,
247
- height: 32,
248
- },
249
- markings: "graph",
250
- labels: ["x", "y"],
251
- showProtractor: false,
252
- showRuler: false,
253
- rulerLabel: "",
254
- rulerTicks: 10,
255
- range: [
256
- [-10, 10],
257
- [-10, 10],
258
- ],
259
- gridStep: [1, 1],
260
- snapStep: [0.5, 0.5],
261
- graph: {type: "linear"},
262
- correct: {type: "linear", coords: null},
263
- },
264
- version: {major: 0, minor: 0},
265
- },
266
- "measurer 1": {
267
- type: "measurer",
268
- graded: true,
269
- options: {
270
- box: [480, 480],
271
- image: {url: "measurer-a"},
272
- showProtractor: true,
273
- showRuler: false,
274
- rulerLabel: "",
275
- rulerTicks: 10,
276
- rulerPixels: 40,
277
- rulerLength: 10,
278
- },
279
- version: {major: 1, minor: 0},
280
- },
281
- "plotter 1": {
282
- type: "plotter",
283
- graded: true,
284
- options: {
285
- correct: [1, 1],
286
- starting: [1, 1],
287
- type: "pic",
288
- labels: ["", ""],
289
- categories: ["a", "a"],
290
- scaleY: 1,
291
- maxY: 10,
292
- snapsPerLine: 2,
293
- labelInterval: 1,
294
- picUrl: "plotter-a",
295
- },
296
- version: {major: 0, minor: 0},
297
- },
298
- },
299
- },
300
- answerArea: {calculator: false},
301
- itemDataVersion: {major: 0, minor: 1},
302
- hints: [
303
- {
304
- content:
305
- "![hint1-a](hint1-a)\n\n![hint1-b](hint1-b)\n\n[[☃ image 1]]",
306
- images: {},
307
- widgets: {
308
- "image 1": {
309
- type: "image",
310
- graded: true,
311
- options: {
312
- title: "![hint1-image-title-a](hint1-image-title-a) ![hint1-image-title-b](hint1-image-title-b)",
313
- range: [
314
- [0, 10],
315
- [0, 10],
316
- ],
317
- box: [0, 0],
318
- backgroundImage: {
319
- url: "hint1-image-a",
320
- width: 0,
321
- height: 0,
322
- },
323
- labels: [],
324
- alt: "",
325
- caption:
326
- "![hint1-image-caption-a](hint1-image-caption-a) ![hint1-image-caption-b](hint1-image-caption-b)",
327
- },
328
- version: {major: 0, minor: 0},
329
- },
330
- },
331
- },
332
- {
333
- content:
334
- "![hint2-a](hint2-a)\n\n![hint2-b](hint2-b)\n\n[[☃ image 1]]",
335
- images: {},
336
- widgets: {
337
- "image 1": {
338
- type: "image",
339
- graded: true,
340
- options: {
341
- title: "![hint2-image-title-a](hint2-image-title-a) ![hint2-image-title-b](hint2-image-title-b)",
342
- range: [
343
- [0, 10],
344
- [0, 10],
345
- ],
346
- box: [0, 0],
347
- backgroundImage: {
348
- url: "hint2-image-a",
349
- width: 0,
350
- height: 0,
351
- },
352
- labels: [],
353
- alt: "",
354
- caption:
355
- "![hint2-image-caption-a](hint2-image-caption-a) ![hint2-image-caption-b](hint2-image-caption-b)",
356
- },
357
- version: {major: 0, minor: 0},
358
- },
359
- },
360
- },
361
- ],
362
- } as const;
363
-
364
- // Article perseus format is very similar to exercises and should parse the
365
- // same way, but should just be a list of renders. So we reuse the test data
366
- // from exerciseImagesEverywhere, but include the question and hints as if they
367
- // were paragraphs in the article.
368
- const articleImagesEverywhere = [exerciseImagesEverywhere.question].concat(
369
- // @ts-expect-error - TS2769 - No overload matches this call.
370
- exerciseImagesEverywhere.hints,
371
- );
372
-
373
- // All of the images that are in the `exerciseImagesEverywhere` item. Also the
374
- // same list of images that are in the `articleImagesEverywhere` item.
375
- const allImages = [
376
- "question-a",
377
- "question-b",
378
- "category-category-a",
379
- "category-category-b",
380
- "category-item-a",
381
- "category-item-b",
382
- "group-a",
383
- "group-b",
384
- "group-image-title-a",
385
- "group-image-title-b",
386
- "group-image-a",
387
- "group-image-caption-a",
388
- "group-image-caption-b",
389
- "image-title-a",
390
- "image-title-b",
391
- "image-a",
392
- "image-caption-a",
393
- "image-caption-b",
394
- "matcher-label-a",
395
- "matcher-label-b",
396
- "matcher-left-a",
397
- "matcher-left-b",
398
- "matcher-right-a",
399
- "matcher-right-b",
400
- "matrix-prefix-a",
401
- "matrix-prefix-b",
402
- "matrix-suffix-a",
403
- "matrix-suffix-b",
404
- "orderer-correct-a",
405
- "orderer-correct-b",
406
- "orderer-other-a",
407
- "orderer-other-b",
408
- "passage-title-a",
409
- "passage-title-b",
410
- "radio-choice1-a",
411
- "radio-choice1-b",
412
- "radio-choice2-a",
413
- "radio-choice2-b",
414
- "sorter-correct-a",
415
- "sorter-correct-b",
416
- "sorter-correct-c",
417
- "table-header-a",
418
- "table-header-b",
419
- "table-header-c",
420
- "grapher-a",
421
- "interactive-graph-a",
422
- "measurer-a",
423
- "plotter-a",
424
- "hint1-a",
425
- "hint1-a",
426
- "hint1-image-title-a",
427
- "hint1-image-title-b",
428
- "hint1-image-a",
429
- "hint1-image-caption-a",
430
- "hint1-image-caption-b",
431
- "hint2-a",
432
- "hint2-a",
433
- "hint2-image-title-a",
434
- "hint2-image-title-b",
435
- "hint2-image-a",
436
- "hint2-image-caption-a",
437
- "hint2-image-caption-b",
438
- ];
439
-
440
- describe("i18n", () => {
441
- beforeAll(() => {
442
- registerAllWidgetsAndEditorsForTesting();
443
- });
444
-
445
- beforeEach(() => {
446
- jest.spyOn(Dependencies, "getDependencies").mockReturnValue(
447
- testDependencies,
448
- );
449
- });
450
-
451
- describe("Exercise image finding", () => {
452
- it("should find all of the images in items", () => {
453
- const foundImages = i18n.findImagesInItemData(
454
- exerciseImagesEverywhere,
455
- );
456
-
457
- expect(foundImages.length <= allImages.length).toBeTruthy();
458
-
459
- _.each(allImages, (image) => {
460
- expect(foundImages.indexOf(image) !== -1).toBeTruthy();
461
- });
462
- });
463
- });
464
-
465
- describe("Article image finding", () => {
466
- it("should find all of the images in items", () => {
467
- const foundImages = i18n.findImagesInArticles(
468
- articleImagesEverywhere,
469
- );
470
-
471
- expect(foundImages.length <= allImages.length).toBeTruthy();
472
-
473
- _.each(allImages, (image) => {
474
- expect(foundImages.indexOf(image) !== -1).toBeTruthy();
475
- });
476
- });
477
- });
478
-
479
- describe("Multi-item image finding", () => {
480
- it("should find all of the images in each leaf node", () => {
481
- const foundImages = i18n.findImagesInItemData({
482
- _multi: {
483
- question: {
484
- __type: "content",
485
- ...exerciseImagesEverywhere.question,
486
- },
487
- hints: exerciseImagesEverywhere.hints.map((hint) => ({
488
- __type: "hint",
489
- ...hint,
490
- })),
491
- },
492
- });
493
-
494
- expect(foundImages.length <= allImages.length).toBeTruthy();
495
-
496
- _.each(allImages, (image) => {
497
- expect(foundImages.indexOf(image) !== -1).toBeTruthy();
498
- });
499
- });
500
- });
501
- });
@@ -1,5 +0,0 @@
1
- describe("PerseusEditor integration test", () => {
2
- it("entrypoint should not throw", async () => {
3
- expect(async () => await import("../index")).not.toThrow();
4
- });
5
- });
@@ -1,85 +0,0 @@
1
- import "@testing-library/jest-dom";
2
- import {render, screen} from "@testing-library/react";
3
- import userEvent from "@testing-library/user-event";
4
- import React from "react";
5
-
6
- import ItemExtrasEditor from "../item-extras-editor";
7
-
8
- describe("ItemExtrasEditor", () => {
9
- it("should render correctly with default props", () => {
10
- // Act
11
- render(<ItemExtrasEditor onChange={() => {}} />);
12
-
13
- // Assert
14
- expect(screen.getByLabelText("Show calculator:")).not.toBeChecked();
15
- expect(screen.getByLabelText("Show periodic table:")).not.toBeChecked();
16
- expect(
17
- screen.queryByText("Include key/legend with periodic table:"),
18
- ).not.toBeInTheDocument();
19
- expect(
20
- screen.getByLabelText("Show z table (statistics):"),
21
- ).not.toBeChecked();
22
- expect(
23
- screen.getByLabelText("Show t table (statistics):"),
24
- ).not.toBeChecked();
25
- expect(
26
- screen.getByLabelText("Show chi-squared table (statistics):"),
27
- ).not.toBeChecked();
28
- });
29
-
30
- it("should call onChange with updated calculator value", () => {
31
- // Arrange
32
- const onChangeMock = jest.fn();
33
- render(<ItemExtrasEditor calculator={false} onChange={onChangeMock} />);
34
- const checkbox = screen.getByLabelText("Show calculator:");
35
-
36
- // Act
37
- userEvent.click(checkbox);
38
-
39
- // Assert
40
- expect(onChangeMock).toHaveBeenCalledWith({calculator: true});
41
- });
42
-
43
- it("should call onChange with updated periodicTableWithKey value when periodicTable is unchecked", () => {
44
- // Arrange
45
- const onChangeMock = jest.fn();
46
- render(
47
- <ItemExtrasEditor
48
- periodicTable={true}
49
- periodicTableWithKey={true}
50
- onChange={onChangeMock}
51
- />,
52
- );
53
- const checkbox = screen.getByLabelText("Show periodic table:");
54
-
55
- // Act
56
- userEvent.click(checkbox);
57
-
58
- // Assert
59
- // visible when periodicTable is checked
60
- expect(
61
- screen.getByText("Include key/legend with periodic table:"),
62
- ).toBeInTheDocument();
63
- expect(onChangeMock).toHaveBeenCalledWith({
64
- periodicTable: false,
65
- periodicTableWithKey: false,
66
- });
67
- });
68
-
69
- it("should call onChange on dependent values when financialCalculator is checked", () => {
70
- // Arrange
71
- const onChangeMock = jest.fn();
72
- render(<ItemExtrasEditor onChange={onChangeMock} />);
73
- const checkbox = screen.getByLabelText("Show financial calculator:");
74
-
75
- // Act
76
- userEvent.click(checkbox);
77
-
78
- // Assert
79
- expect(onChangeMock).toHaveBeenCalledWith({
80
- financialCalculatorMonthlyPayment: true,
81
- financialCalculatorTotalAmount: true,
82
- financialCalculatorTimeToPayOff: true,
83
- });
84
- });
85
- });