@pie-element/hotspot 4.8.0 → 4.8.1-beta.587
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/CHANGELOG.md +474 -0
- package/configure/CHANGELOG.md +417 -0
- package/configure/lib/button.js.map +1 -1
- package/configure/lib/defaults.js +24 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/hotspot-container.js +44 -23
- package/configure/lib/hotspot-container.js.map +1 -1
- package/configure/lib/hotspot-drawable.js +11 -5
- package/configure/lib/hotspot-drawable.js.map +1 -1
- package/configure/lib/hotspot-palette.js +1 -1
- package/configure/lib/hotspot-palette.js.map +1 -1
- package/configure/lib/hotspot-polygon.js +1 -1
- package/configure/lib/hotspot-polygon.js.map +1 -1
- package/configure/lib/hotspot-rectangle.js +1 -1
- package/configure/lib/hotspot-rectangle.js.map +1 -1
- package/configure/lib/index.js +17 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +133 -27
- package/configure/lib/root.js.map +1 -1
- package/configure/lib/upload-control.js.map +1 -1
- package/configure/lib/utils.js +18 -4
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +4 -4
- package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +2 -1
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +56 -4
- package/configure/src/__tests__/hotspot-container.test.js +98 -71
- package/configure/src/__tests__/hotspot-drawable.test.js +48 -49
- package/configure/src/__tests__/index.test.js +28 -51
- package/configure/src/__tests__/root.test.js +162 -82
- package/configure/src/__tests__/utils.test.js +112 -98
- package/configure/src/button.jsx +4 -4
- package/configure/src/defaults.js +36 -18
- package/configure/src/hotspot-container.jsx +107 -97
- package/configure/src/hotspot-drawable.jsx +59 -53
- package/configure/src/hotspot-palette.jsx +12 -25
- package/configure/src/hotspot-polygon.jsx +20 -22
- package/configure/src/hotspot-rectangle.jsx +5 -15
- package/configure/src/index.js +32 -18
- package/configure/src/root.jsx +120 -51
- package/configure/src/upload-control.jsx +9 -20
- package/configure/src/utils.js +51 -22
- package/controller/CHANGELOG.md +61 -0
- package/controller/lib/defaults.js +2 -2
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +57 -9
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +2 -2
- package/controller/src/__tests__/index.test.js +99 -55
- package/controller/src/defaults.js +5 -9
- package/controller/src/index.js +58 -34
- package/controller/src/utils.js +9 -6
- package/docs/config-schema.json +217 -0
- package/docs/config-schema.json.md +169 -0
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +54 -35
- package/docs/demo/session.js +2 -2
- package/docs/pie-schema.json +59 -0
- package/docs/pie-schema.json.md +47 -0
- package/lib/hotspot/container.js +44 -7
- package/lib/hotspot/container.js.map +1 -1
- package/lib/hotspot/icons.js.map +1 -1
- package/lib/hotspot/image.js +35 -8
- package/lib/hotspot/image.js.map +1 -1
- package/lib/hotspot/index.js +72 -18
- package/lib/hotspot/index.js.map +1 -1
- package/lib/hotspot/polygon.js +51 -32
- package/lib/hotspot/polygon.js.map +1 -1
- package/lib/hotspot/rectangle.js +51 -32
- package/lib/hotspot/rectangle.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/session-updater.js.map +1 -1
- package/package.json +7 -4
- package/src/__tests__/__snapshots__/{container-test.jsx.snap → container.test.jsx.snap} +8 -0
- package/src/__tests__/__snapshots__/image.test.jsx.snap +43 -0
- package/src/__tests__/__snapshots__/{polygon-test.jsx.snap → polygon.test.jsx.snap} +11 -0
- package/src/__tests__/__snapshots__/{rectangle-test.jsx.snap → rectangle.test.jsx.snap} +11 -0
- package/src/__tests__/container.test.jsx +214 -0
- package/src/__tests__/{image-test.jsx → image.test.jsx} +10 -2
- package/src/__tests__/polygon.test.jsx +235 -0
- package/src/__tests__/rectangle.test.jsx +237 -0
- package/src/__tests__/{session-updater-test.jsx → session-updater.test.jsx} +22 -31
- package/src/hotspot/container.jsx +60 -23
- package/src/hotspot/icons.js +4 -2
- package/src/hotspot/image.jsx +26 -13
- package/src/hotspot/index.jsx +73 -33
- package/src/hotspot/polygon.jsx +51 -40
- package/src/hotspot/rectangle.jsx +51 -40
- package/src/index.js +10 -18
- package/src/session-updater.js +1 -1
- package/src/__tests__/__snapshots__/image-test.jsx.snap +0 -21
- package/src/__tests__/container-test.jsx +0 -143
- package/src/__tests__/polygon-test.jsx +0 -76
- package/src/__tests__/rectangle-test.jsx +0 -77
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
exports[`HotspotContainer render renders 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
className="
|
|
6
|
+
className=""
|
|
7
7
|
onDragExit={[Function]}
|
|
8
8
|
onDragLeave={[Function]}
|
|
9
9
|
onDragOver={[Function]}
|
|
10
10
|
onDrop={[Function]}
|
|
11
|
+
onPaste={[Function]}
|
|
11
12
|
>
|
|
12
13
|
<div>
|
|
13
14
|
<WithStyles(UploadControl)
|
|
@@ -3,10 +3,22 @@
|
|
|
3
3
|
exports[`Root render renders 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<ConfigLayout
|
|
6
|
+
hideSettings={false}
|
|
6
7
|
settings={
|
|
7
8
|
<Panel
|
|
8
9
|
configuration={
|
|
9
10
|
Object {
|
|
11
|
+
"maxImageHeight": Object {
|
|
12
|
+
"prompt": 300,
|
|
13
|
+
"rationale": 300,
|
|
14
|
+
"teacherInstructions": 300,
|
|
15
|
+
},
|
|
16
|
+
"maxImageWidth": Object {
|
|
17
|
+
"prompt": 300,
|
|
18
|
+
"rationale": 300,
|
|
19
|
+
"teacherInstructions": 300,
|
|
20
|
+
},
|
|
21
|
+
"minShapes": 2,
|
|
10
22
|
"multipleCorrect": Object {
|
|
11
23
|
"label": "Multiple Correct Responses",
|
|
12
24
|
"settings": true,
|
|
@@ -28,16 +40,28 @@ exports[`Root render renders 1`] = `
|
|
|
28
40
|
"label": "Rationale",
|
|
29
41
|
"settings": true,
|
|
30
42
|
},
|
|
43
|
+
"settingsPanelDisabled": false,
|
|
44
|
+
"spellCheck": Object {
|
|
45
|
+
"enabled": true,
|
|
46
|
+
"label": "Spellcheck",
|
|
47
|
+
"settings": false,
|
|
48
|
+
},
|
|
31
49
|
"teacherInstructions": Object {
|
|
32
50
|
"label": "Teacher Instructions",
|
|
33
51
|
"settings": true,
|
|
34
52
|
},
|
|
53
|
+
"withRubric": Object {
|
|
54
|
+
"label": "Add Rubric",
|
|
55
|
+
"settings": false,
|
|
56
|
+
},
|
|
35
57
|
}
|
|
36
58
|
}
|
|
37
59
|
groups={
|
|
38
60
|
Object {
|
|
39
61
|
"Properties": Object {
|
|
40
62
|
"rationaleEnabled": undefined,
|
|
63
|
+
"rubricEnabled": false,
|
|
64
|
+
"spellCheckEnabled": false,
|
|
41
65
|
"teacherInstructionsEnabled": undefined,
|
|
42
66
|
},
|
|
43
67
|
"Settings": Object {
|
|
@@ -170,11 +194,38 @@ exports[`Root render renders 1`] = `
|
|
|
170
194
|
}
|
|
171
195
|
>
|
|
172
196
|
<div>
|
|
173
|
-
<
|
|
174
|
-
|
|
197
|
+
<div
|
|
198
|
+
className=""
|
|
175
199
|
>
|
|
176
|
-
|
|
177
|
-
|
|
200
|
+
<WithStyles(Typography)
|
|
201
|
+
variant="subheading"
|
|
202
|
+
>
|
|
203
|
+
Define Hotspot
|
|
204
|
+
</WithStyles(Typography)>
|
|
205
|
+
<WithStyles(Tooltip)
|
|
206
|
+
classes={
|
|
207
|
+
Object {
|
|
208
|
+
"tooltip": undefined,
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
disableFocusListener={true}
|
|
212
|
+
disableTouchListener={true}
|
|
213
|
+
placement="left"
|
|
214
|
+
title="Validation requirements:
|
|
215
|
+
There should be at least 2 shapes defined.
|
|
216
|
+
There should be at least 1 shape selected."
|
|
217
|
+
>
|
|
218
|
+
<pure(InfoIcon)
|
|
219
|
+
color="primary"
|
|
220
|
+
fontSize="small"
|
|
221
|
+
style={
|
|
222
|
+
Object {
|
|
223
|
+
"float": "right",
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/>
|
|
227
|
+
</WithStyles(Tooltip)>
|
|
228
|
+
</div>
|
|
178
229
|
<WithStyles(Palette)
|
|
179
230
|
hotspotColor="rgba(137, 183, 244, 0.65)"
|
|
180
231
|
hotspotList={
|
|
@@ -202,6 +253,7 @@ exports[`Root render renders 1`] = `
|
|
|
202
253
|
"width": 400,
|
|
203
254
|
}
|
|
204
255
|
}
|
|
256
|
+
hasErrors={false}
|
|
205
257
|
hotspotColor="rgba(137, 183, 244, 0.65)"
|
|
206
258
|
imageUrl="https://cdn.fluence.net/image/0240eb1455ce4c4bb6180232347b6aef_W"
|
|
207
259
|
multipleCorrect={true}
|
|
@@ -5,50 +5,73 @@ import { getAllShapes, groupShapes } from '../utils';
|
|
|
5
5
|
|
|
6
6
|
const model = () => ({
|
|
7
7
|
imageUrl: 'https://cdn.fluence.net/image/0240eb1455ce4c4bb6180232347b6aef_W',
|
|
8
|
-
shapes: groupShapes(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
8
|
+
shapes: groupShapes(
|
|
9
|
+
getAllShapes({
|
|
10
|
+
rectangles: [
|
|
11
|
+
{
|
|
12
|
+
id: '0',
|
|
13
|
+
height: 140,
|
|
14
|
+
width: 130,
|
|
15
|
+
x: 1,
|
|
16
|
+
y: 1,
|
|
17
|
+
correct: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: '1',
|
|
21
|
+
height: 140,
|
|
22
|
+
width: 130,
|
|
23
|
+
x: 140,
|
|
24
|
+
y: 1,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: '2',
|
|
28
|
+
height: 140,
|
|
29
|
+
width: 130,
|
|
30
|
+
x: 280,
|
|
31
|
+
y: 1,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
polygons: [
|
|
35
|
+
{
|
|
36
|
+
id: '3',
|
|
37
|
+
points: [
|
|
38
|
+
{ x: 1, y: 148 },
|
|
39
|
+
{ x: 1, y: 288 },
|
|
40
|
+
{ y: 288, x: 129 },
|
|
41
|
+
{ y: 148, x: 129 },
|
|
42
|
+
],
|
|
43
|
+
correct: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: '4',
|
|
47
|
+
points: [
|
|
48
|
+
{ y: 151, x: 141 },
|
|
49
|
+
{ y: 289, x: 141 },
|
|
50
|
+
{ y: 289, x: 269 },
|
|
51
|
+
{ x: 269, y: 151 },
|
|
52
|
+
],
|
|
53
|
+
correct: false,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: '5',
|
|
57
|
+
points: [
|
|
58
|
+
{ x: 279, y: 150 },
|
|
59
|
+
{ x: 279, y: 289 },
|
|
60
|
+
{ x: 407, y: 289 },
|
|
61
|
+
{ x: 407, y: 150 },
|
|
62
|
+
],
|
|
63
|
+
correct: false,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}),
|
|
67
|
+
),
|
|
46
68
|
dimensions: {
|
|
47
|
-
height: 291,
|
|
69
|
+
height: 291,
|
|
70
|
+
width: 410,
|
|
48
71
|
},
|
|
49
72
|
hotspotColor: 'rgba(137, 183, 244, 0.65)',
|
|
50
73
|
outlineColor: 'blue',
|
|
51
|
-
multipleCorrect: true
|
|
74
|
+
multipleCorrect: true,
|
|
52
75
|
});
|
|
53
76
|
|
|
54
77
|
describe('HotspotContainer', () => {
|
|
@@ -56,11 +79,9 @@ describe('HotspotContainer', () => {
|
|
|
56
79
|
onImageUpload = jest.fn(),
|
|
57
80
|
onUpdateImageDimension = jest.fn(),
|
|
58
81
|
onUpdateShapes = jest.fn(),
|
|
59
|
-
initialModel = model()
|
|
60
|
-
;
|
|
61
|
-
|
|
82
|
+
initialModel = model();
|
|
62
83
|
beforeEach(() => {
|
|
63
|
-
w = extras => {
|
|
84
|
+
w = (extras) => {
|
|
64
85
|
const props = {
|
|
65
86
|
classes: {},
|
|
66
87
|
dimensions: initialModel.dimensions,
|
|
@@ -72,17 +93,17 @@ describe('HotspotContainer', () => {
|
|
|
72
93
|
onUpdateShapes: onUpdateShapes,
|
|
73
94
|
onImageUpload: onImageUpload,
|
|
74
95
|
shapes: initialModel.shapes,
|
|
75
|
-
...extras
|
|
96
|
+
...extras,
|
|
76
97
|
};
|
|
77
98
|
|
|
78
99
|
return shallow(<Container {...props} />);
|
|
79
|
-
}
|
|
100
|
+
};
|
|
80
101
|
});
|
|
81
102
|
|
|
82
103
|
describe('render', () => {
|
|
83
104
|
it('renders', () => {
|
|
84
105
|
expect(w()).toMatchSnapshot();
|
|
85
|
-
})
|
|
106
|
+
});
|
|
86
107
|
});
|
|
87
108
|
|
|
88
109
|
describe('logic', () => {
|
|
@@ -96,23 +117,25 @@ describe('HotspotContainer', () => {
|
|
|
96
117
|
y: 1,
|
|
97
118
|
correct: true,
|
|
98
119
|
group: 'rectangles',
|
|
99
|
-
index: 0
|
|
100
|
-
},
|
|
120
|
+
index: 0,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
101
123
|
id: '1',
|
|
102
124
|
height: 140,
|
|
103
125
|
width: 130,
|
|
104
126
|
x: 140,
|
|
105
127
|
y: 1,
|
|
106
128
|
group: 'rectangles',
|
|
107
|
-
index: 1
|
|
108
|
-
},
|
|
129
|
+
index: 1,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
109
132
|
id: '2',
|
|
110
133
|
height: 140,
|
|
111
134
|
width: 130,
|
|
112
135
|
x: 280,
|
|
113
136
|
y: 1,
|
|
114
137
|
group: 'rectangles',
|
|
115
|
-
index: 2
|
|
138
|
+
index: 2,
|
|
116
139
|
},
|
|
117
140
|
{
|
|
118
141
|
id: '3',
|
|
@@ -120,32 +143,36 @@ describe('HotspotContainer', () => {
|
|
|
120
143
|
{ x: 1, y: 148 },
|
|
121
144
|
{ x: 1, y: 288 },
|
|
122
145
|
{ y: 288, x: 129 },
|
|
123
|
-
{ y: 148, x: 129 }
|
|
146
|
+
{ y: 148, x: 129 },
|
|
147
|
+
],
|
|
124
148
|
correct: true,
|
|
125
149
|
group: 'polygons',
|
|
126
|
-
index: 3
|
|
127
|
-
},
|
|
150
|
+
index: 3,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
128
153
|
id: '4',
|
|
129
154
|
points: [
|
|
130
155
|
{ y: 151, x: 141 },
|
|
131
156
|
{ y: 289, x: 141 },
|
|
132
157
|
{ y: 289, x: 269 },
|
|
133
|
-
{ x: 269, y: 151 }
|
|
158
|
+
{ x: 269, y: 151 },
|
|
159
|
+
],
|
|
134
160
|
correct: false,
|
|
135
161
|
group: 'polygons',
|
|
136
|
-
index: 4
|
|
137
|
-
},
|
|
162
|
+
index: 4,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
138
165
|
id: '5',
|
|
139
166
|
points: [
|
|
140
167
|
{ x: 279, y: 150 },
|
|
141
168
|
{ x: 279, y: 289 },
|
|
142
169
|
{ x: 407, y: 289 },
|
|
143
|
-
{ x: 407, y: 150 }
|
|
170
|
+
{ x: 407, y: 150 },
|
|
144
171
|
],
|
|
145
172
|
correct: false,
|
|
146
173
|
group: 'polygons',
|
|
147
|
-
index: 5
|
|
148
|
-
}
|
|
174
|
+
index: 5,
|
|
175
|
+
},
|
|
149
176
|
];
|
|
150
177
|
|
|
151
178
|
beforeEach(() => {
|
|
@@ -163,7 +190,7 @@ describe('HotspotContainer', () => {
|
|
|
163
190
|
width: 130,
|
|
164
191
|
x: 280,
|
|
165
192
|
y: 1,
|
|
166
|
-
group: 'rectangles'
|
|
193
|
+
group: 'rectangles',
|
|
167
194
|
};
|
|
168
195
|
|
|
169
196
|
wrapper.instance().onUpdateShapes([...formattedShapes, newShape]);
|
|
@@ -177,10 +204,10 @@ describe('HotspotContainer', () => {
|
|
|
177
204
|
width: 130,
|
|
178
205
|
x: 280,
|
|
179
206
|
y: 1,
|
|
180
|
-
}
|
|
207
|
+
},
|
|
181
208
|
],
|
|
182
|
-
polygons: initialModel.shapes.polygons
|
|
183
|
-
})
|
|
209
|
+
polygons: initialModel.shapes.polygons,
|
|
210
|
+
});
|
|
184
211
|
});
|
|
185
212
|
|
|
186
213
|
it('onUpdateShapes with no shapes', () => {
|
|
@@ -188,15 +215,15 @@ describe('HotspotContainer', () => {
|
|
|
188
215
|
|
|
189
216
|
expect(onUpdateShapes).toHaveBeenLastCalledWith({
|
|
190
217
|
rectangles: [],
|
|
191
|
-
polygons: []
|
|
192
|
-
})
|
|
218
|
+
polygons: [],
|
|
219
|
+
});
|
|
193
220
|
});
|
|
194
221
|
|
|
195
222
|
it('handleUndo if no new shape was added', () => {
|
|
196
223
|
wrapper.instance().handleUndo();
|
|
197
224
|
expect(onUpdateShapes).toHaveBeenLastCalledWith({
|
|
198
225
|
...initialModel.shapes,
|
|
199
|
-
polygons: initialModel.shapes.polygons.slice(0, -1)
|
|
226
|
+
polygons: initialModel.shapes.polygons.slice(0, -1),
|
|
200
227
|
});
|
|
201
228
|
});
|
|
202
229
|
|
|
@@ -207,13 +234,13 @@ describe('HotspotContainer', () => {
|
|
|
207
234
|
width: 130,
|
|
208
235
|
x: 280,
|
|
209
236
|
y: 1,
|
|
210
|
-
index: 6
|
|
237
|
+
index: 6,
|
|
211
238
|
};
|
|
212
239
|
|
|
213
240
|
// first, add a new shape
|
|
214
241
|
wrapper.instance().state.shapes = getAllShapes({
|
|
215
242
|
...initialModel.shapes,
|
|
216
|
-
rectangles: [
|
|
243
|
+
rectangles: [...initialModel.shapes.rectangles, newShape],
|
|
217
244
|
});
|
|
218
245
|
wrapper.instance().handleUndo();
|
|
219
246
|
expect(onUpdateShapes).toBeCalledWith(initialModel.shapes);
|
|
@@ -223,7 +250,7 @@ describe('HotspotContainer', () => {
|
|
|
223
250
|
wrapper.instance().handleClearAll();
|
|
224
251
|
expect(onUpdateShapes).toHaveBeenLastCalledWith({
|
|
225
252
|
rectangles: [],
|
|
226
|
-
polygons: []
|
|
253
|
+
polygons: [],
|
|
227
254
|
});
|
|
228
255
|
});
|
|
229
256
|
});
|
|
@@ -12,21 +12,23 @@ const model = () => ({
|
|
|
12
12
|
x: 1,
|
|
13
13
|
y: 1,
|
|
14
14
|
correct: true,
|
|
15
|
-
group: 'rectangles'
|
|
16
|
-
},
|
|
15
|
+
group: 'rectangles',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
17
18
|
id: '1',
|
|
18
19
|
height: 140,
|
|
19
20
|
width: 130,
|
|
20
21
|
x: 140,
|
|
21
22
|
y: 1,
|
|
22
|
-
group: 'rectangles'
|
|
23
|
-
},
|
|
23
|
+
group: 'rectangles',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
24
26
|
id: '2',
|
|
25
27
|
height: 140,
|
|
26
28
|
width: 130,
|
|
27
29
|
x: 280,
|
|
28
30
|
y: 1,
|
|
29
|
-
group: 'rectangles'
|
|
31
|
+
group: 'rectangles',
|
|
30
32
|
},
|
|
31
33
|
{
|
|
32
34
|
id: '3',
|
|
@@ -34,32 +36,37 @@ const model = () => ({
|
|
|
34
36
|
{ x: 1, y: 148 },
|
|
35
37
|
{ x: 1, y: 288 },
|
|
36
38
|
{ y: 288, x: 129 },
|
|
37
|
-
{ y: 148, x: 129 }
|
|
39
|
+
{ y: 148, x: 129 },
|
|
40
|
+
],
|
|
38
41
|
correct: true,
|
|
39
|
-
group: 'polygons'
|
|
40
|
-
},
|
|
42
|
+
group: 'polygons',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
41
45
|
id: '4',
|
|
42
46
|
points: [
|
|
43
47
|
{ y: 151, x: 141 },
|
|
44
48
|
{ y: 289, x: 141 },
|
|
45
49
|
{ y: 289, x: 269 },
|
|
46
|
-
{ x: 269, y: 151 }
|
|
50
|
+
{ x: 269, y: 151 },
|
|
51
|
+
],
|
|
47
52
|
correct: false,
|
|
48
|
-
group: 'polygons'
|
|
49
|
-
},
|
|
53
|
+
group: 'polygons',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
50
56
|
id: '5',
|
|
51
57
|
points: [
|
|
52
58
|
{ x: 279, y: 150 },
|
|
53
59
|
{ x: 279, y: 289 },
|
|
54
60
|
{ x: 407, y: 289 },
|
|
55
|
-
{ x: 407, y: 150 }
|
|
61
|
+
{ x: 407, y: 150 },
|
|
56
62
|
],
|
|
57
63
|
correct: false,
|
|
58
|
-
group: 'polygons'
|
|
59
|
-
}
|
|
64
|
+
group: 'polygons',
|
|
65
|
+
},
|
|
60
66
|
],
|
|
61
67
|
dimensions: {
|
|
62
|
-
height: 291,
|
|
68
|
+
height: 291,
|
|
69
|
+
width: 410,
|
|
63
70
|
},
|
|
64
71
|
hotspotColor: 'rgba(137, 183, 244, 0.65)',
|
|
65
72
|
outlineColor: 'blue',
|
|
@@ -72,11 +79,9 @@ describe('HotspotDrawable', () => {
|
|
|
72
79
|
handleEnableDrag = jest.fn(),
|
|
73
80
|
onUpdateImageDimension = jest.fn(),
|
|
74
81
|
onUpdateShapes = jest.fn(),
|
|
75
|
-
initialModel = model()
|
|
76
|
-
;
|
|
77
|
-
|
|
82
|
+
initialModel = model();
|
|
78
83
|
beforeEach(() => {
|
|
79
|
-
w = extras => {
|
|
84
|
+
w = (extras) => {
|
|
80
85
|
const props = {
|
|
81
86
|
classes: {},
|
|
82
87
|
dimensions: initialModel.dimensions,
|
|
@@ -90,11 +95,11 @@ describe('HotspotDrawable', () => {
|
|
|
90
95
|
outlineColor: initialModel.outlineColor,
|
|
91
96
|
shapes: initialModel.shapes,
|
|
92
97
|
strokeWidth: 5,
|
|
93
|
-
...extras
|
|
98
|
+
...extras,
|
|
94
99
|
};
|
|
95
100
|
|
|
96
101
|
return shallow(<Drawable {...props} />);
|
|
97
|
-
}
|
|
102
|
+
};
|
|
98
103
|
});
|
|
99
104
|
|
|
100
105
|
describe('render', () => {
|
|
@@ -126,8 +131,8 @@ describe('HotspotDrawable', () => {
|
|
|
126
131
|
currentTarget: 'Stage',
|
|
127
132
|
evt: {
|
|
128
133
|
layerX: 20,
|
|
129
|
-
layerY: 30
|
|
130
|
-
}
|
|
134
|
+
layerY: 30,
|
|
135
|
+
},
|
|
131
136
|
};
|
|
132
137
|
|
|
133
138
|
wrapper.instance().handleOnMouseDown(event);
|
|
@@ -141,8 +146,8 @@ describe('HotspotDrawable', () => {
|
|
|
141
146
|
currentTarget: 'Stage',
|
|
142
147
|
evt: {
|
|
143
148
|
layerX: 20,
|
|
144
|
-
layerY: 30
|
|
145
|
-
}
|
|
149
|
+
layerY: 30,
|
|
150
|
+
},
|
|
146
151
|
};
|
|
147
152
|
|
|
148
153
|
wrapper.instance().handleOnMouseDown(event);
|
|
@@ -156,8 +161,8 @@ describe('HotspotDrawable', () => {
|
|
|
156
161
|
x: 20,
|
|
157
162
|
y: 30,
|
|
158
163
|
group: 'rectangles',
|
|
159
|
-
index: 6
|
|
160
|
-
}
|
|
164
|
+
index: 6,
|
|
165
|
+
},
|
|
161
166
|
]);
|
|
162
167
|
});
|
|
163
168
|
|
|
@@ -168,8 +173,8 @@ describe('HotspotDrawable', () => {
|
|
|
168
173
|
wrapper.instance().handleOnMouseUp({
|
|
169
174
|
evt: {
|
|
170
175
|
layerX: 20,
|
|
171
|
-
layerY: 30
|
|
172
|
-
}
|
|
176
|
+
layerY: 30,
|
|
177
|
+
},
|
|
173
178
|
});
|
|
174
179
|
|
|
175
180
|
expect(onUpdateShapes).toHaveBeenCalledWith([...initialModel.shapes.slice(0, 2)]);
|
|
@@ -180,48 +185,43 @@ describe('HotspotDrawable', () => {
|
|
|
180
185
|
wrapper.instance().handleOnMouseUp({
|
|
181
186
|
evt: {
|
|
182
187
|
layerX: 20,
|
|
183
|
-
layerY: 30
|
|
184
|
-
}
|
|
188
|
+
layerY: 30,
|
|
189
|
+
},
|
|
185
190
|
});
|
|
186
191
|
|
|
187
192
|
expect(onUpdateShapes).not.toBeCalledWith(false);
|
|
188
193
|
|
|
189
|
-
|
|
190
194
|
wrapper.instance().handleOnMouseUp({});
|
|
191
195
|
|
|
192
196
|
expect(onUpdateShapes).toHaveBeenCalledWith(initialModel.shapes.slice(0, 2));
|
|
193
197
|
});
|
|
194
198
|
|
|
195
199
|
it('handleOnSetAsCorrect correct', () => {
|
|
196
|
-
wrapper.instance().handleOnSetAsCorrect(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
);
|
|
200
|
+
wrapper.instance().handleOnSetAsCorrect({
|
|
201
|
+
id: '1',
|
|
202
|
+
});
|
|
201
203
|
|
|
202
204
|
expect(onUpdateShapes).toHaveBeenCalledWith([
|
|
203
205
|
initialModel.shapes[0],
|
|
204
206
|
{
|
|
205
207
|
...initialModel.shapes[1],
|
|
206
|
-
correct: true
|
|
208
|
+
correct: true,
|
|
207
209
|
},
|
|
208
|
-
...initialModel.shapes.slice(2)
|
|
210
|
+
...initialModel.shapes.slice(2),
|
|
209
211
|
]);
|
|
210
212
|
});
|
|
211
213
|
|
|
212
214
|
it('handleOnSetAsCorrect incorrect', () => {
|
|
213
|
-
wrapper.instance().handleOnSetAsCorrect(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
);
|
|
215
|
+
wrapper.instance().handleOnSetAsCorrect({
|
|
216
|
+
id: '0',
|
|
217
|
+
});
|
|
218
218
|
|
|
219
219
|
expect(onUpdateShapes).toHaveBeenCalledWith([
|
|
220
220
|
{
|
|
221
221
|
...initialModel.shapes[0],
|
|
222
|
-
correct: false
|
|
222
|
+
correct: false,
|
|
223
223
|
},
|
|
224
|
-
...initialModel.shapes.slice(1)
|
|
224
|
+
...initialModel.shapes.slice(1),
|
|
225
225
|
]);
|
|
226
226
|
});
|
|
227
227
|
|
|
@@ -232,9 +232,9 @@ describe('HotspotDrawable', () => {
|
|
|
232
232
|
{
|
|
233
233
|
...initialModel.shapes[0],
|
|
234
234
|
x: 1,
|
|
235
|
-
y: 1
|
|
235
|
+
y: 1,
|
|
236
236
|
},
|
|
237
|
-
...initialModel.shapes.slice(1)
|
|
237
|
+
...initialModel.shapes.slice(1),
|
|
238
238
|
]);
|
|
239
239
|
});
|
|
240
240
|
|
|
@@ -243,6 +243,5 @@ describe('HotspotDrawable', () => {
|
|
|
243
243
|
|
|
244
244
|
expect(onUpdateShapes).toHaveBeenCalledWith(initialModel.shapes);
|
|
245
245
|
});
|
|
246
|
-
|
|
247
246
|
});
|
|
248
247
|
});
|