@pie-element/hotspot 4.8.4-next.135 → 4.8.4-next.1353

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 (71) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/configure/CHANGELOG.md +233 -0
  3. package/configure/lib/defaults.js +20 -0
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/hotspot-container.js +26 -12
  6. package/configure/lib/hotspot-container.js.map +1 -1
  7. package/configure/lib/hotspot-drawable.js +11 -5
  8. package/configure/lib/hotspot-drawable.js.map +1 -1
  9. package/configure/lib/hotspot-palette.js +1 -1
  10. package/configure/lib/hotspot-palette.js.map +1 -1
  11. package/configure/lib/hotspot-polygon.js +1 -1
  12. package/configure/lib/hotspot-polygon.js.map +1 -1
  13. package/configure/lib/hotspot-rectangle.js +1 -1
  14. package/configure/lib/hotspot-rectangle.js.map +1 -1
  15. package/configure/lib/index.js +17 -3
  16. package/configure/lib/index.js.map +1 -1
  17. package/configure/lib/root.js +107 -13
  18. package/configure/lib/root.js.map +1 -1
  19. package/configure/lib/utils.js +18 -4
  20. package/configure/lib/utils.js.map +1 -1
  21. package/configure/package.json +4 -4
  22. package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +1 -0
  23. package/configure/src/__tests__/__snapshots__/root.test.js.snap +53 -4
  24. package/configure/src/defaults.js +20 -0
  25. package/configure/src/hotspot-container.jsx +16 -5
  26. package/configure/src/hotspot-drawable.jsx +8 -2
  27. package/configure/src/index.js +14 -0
  28. package/configure/src/root.jsx +87 -9
  29. package/configure/src/utils.js +23 -1
  30. package/controller/CHANGELOG.md +50 -0
  31. package/controller/lib/index.js +44 -5
  32. package/controller/lib/index.js.map +1 -1
  33. package/controller/lib/utils.js.map +1 -1
  34. package/controller/package.json +1 -1
  35. package/controller/src/index.js +26 -0
  36. package/docs/config-schema.json +212 -0
  37. package/docs/config-schema.json.md +165 -0
  38. package/docs/demo/generate.js +1 -0
  39. package/docs/pie-schema.json +49 -0
  40. package/docs/pie-schema.json.md +36 -0
  41. package/lib/hotspot/container.js +25 -7
  42. package/lib/hotspot/container.js.map +1 -1
  43. package/lib/hotspot/image.js +1 -1
  44. package/lib/hotspot/image.js.map +1 -1
  45. package/lib/hotspot/index.js +72 -18
  46. package/lib/hotspot/index.js.map +1 -1
  47. package/lib/hotspot/polygon.js +46 -20
  48. package/lib/hotspot/polygon.js.map +1 -1
  49. package/lib/hotspot/rectangle.js +46 -20
  50. package/lib/hotspot/rectangle.js.map +1 -1
  51. package/lib/index.js +4 -1
  52. package/lib/index.js.map +1 -1
  53. package/lib/session-updater.js.map +1 -1
  54. package/package.json +6 -4
  55. package/src/__tests__/__snapshots__/{container-test.jsx.snap → container.test.jsx.snap} +8 -0
  56. package/src/__tests__/__snapshots__/image.test.jsx.snap +43 -0
  57. package/src/__tests__/__snapshots__/{polygon-test.jsx.snap → polygon.test.jsx.snap} +11 -0
  58. package/src/__tests__/__snapshots__/{rectangle-test.jsx.snap → rectangle.test.jsx.snap} +11 -0
  59. package/src/__tests__/{container-test.jsx → container.test.jsx} +57 -0
  60. package/src/__tests__/{image-test.jsx → image.test.jsx} +0 -0
  61. package/src/__tests__/polygon.test.jsx +224 -0
  62. package/src/__tests__/rectangle.test.jsx +233 -0
  63. package/src/__tests__/{session-updater-test.jsx → session-updater.test.jsx} +0 -0
  64. package/src/hotspot/container.jsx +23 -3
  65. package/src/hotspot/index.jsx +68 -8
  66. package/src/hotspot/polygon.jsx +40 -17
  67. package/src/hotspot/rectangle.jsx +40 -17
  68. package/src/index.js +5 -0
  69. package/src/__tests__/__snapshots__/image-test.jsx.snap +0 -21
  70. package/src/__tests__/polygon-test.jsx +0 -77
  71. package/src/__tests__/rectangle-test.jsx +0 -78
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot",
3
- "version": "4.8.4-next.135+4af016191",
3
+ "version": "4.8.4-next.1353+9a034ca32",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -9,8 +9,10 @@
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.3",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
- "@pie-lib/math-rendering": "^2.3.8",
13
- "@pie-lib/render-ui": "^4.11.9",
12
+ "@pie-lib/correct-answer-toggle": "^2.3.46",
13
+ "@pie-lib/math-rendering": "^2.5.0",
14
+ "@pie-lib/render-ui": "^4.13.6",
15
+ "@pie-lib/test-utils": "^0.2.19",
14
16
  "konva": "^3.2.5",
15
17
  "prop-types": "^15.6.1",
16
18
  "react": "^16.8.1",
@@ -19,7 +21,7 @@
19
21
  },
20
22
  "author": "pie framework developers",
21
23
  "license": "ISC",
22
- "gitHead": "4af016191b4e3b79b27fec8365a0e1189e91c4d3",
24
+ "gitHead": "9a034ca32fc88f1a2d178acc5048ae8a1e2e101d",
23
25
  "scripts": {
24
26
  "postpublish": "../../scripts/postpublish"
25
27
  },
@@ -23,6 +23,7 @@ exports[`Container snapshots hotspot color renders 1`] = `
23
23
  isEvaluateMode={false}
24
24
  onSelectChoice={[MockFunction]}
25
25
  outlineColor="blue"
26
+ scale={1}
26
27
  session={
27
28
  Object {
28
29
  "answers": Array [],
@@ -60,6 +61,7 @@ exports[`Container snapshots image renders 1`] = `
60
61
  isEvaluateMode={false}
61
62
  onSelectChoice={[MockFunction]}
62
63
  outlineColor="blue"
64
+ scale={1}
63
65
  session={
64
66
  Object {
65
67
  "answers": Array [],
@@ -97,6 +99,7 @@ exports[`Container snapshots outline color renders 1`] = `
97
99
  isEvaluateMode={false}
98
100
  onSelectChoice={[MockFunction]}
99
101
  outlineColor="red"
102
+ scale={1}
100
103
  session={
101
104
  Object {
102
105
  "answers": Array [],
@@ -134,6 +137,7 @@ exports[`Container snapshots shapes renders 1`] = `
134
137
  isEvaluateMode={false}
135
138
  onSelectChoice={[MockFunction]}
136
139
  outlineColor="blue"
140
+ scale={1}
137
141
  session={
138
142
  Object {
139
143
  "answers": Array [],
@@ -202,6 +206,7 @@ exports[`HotspotComponent renders snapshot with padding having a size accordingl
202
206
  >
203
207
  <div>
204
208
  <img
209
+ alt="hotspot-image"
205
210
  height="auto"
206
211
  src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw8PEA8PDw8PDxAPDg8PDw0PDw8PDw8QFREWFhURFRUYHSggGBomHRUVITEhJSkrLi4uFx8zODMsNygtLysBCgoKDg0OFxAQFy0dHR0tLSstLS0tKy0tLS0tLSstLS0tKy0tLS0tLSstKy0tLS0tLS0tLS0tLS0tLS0tLS0tK//AABEIAKgBLAMBEQACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAABAgADBAUGB//EADoQAAICAQMCBAQEBQMDBQEAAAECAAMRBBIhMUEFE1FhIjJxgQYUQpEjUqGx0WJywUPh8BUkM1PxB//EABoBAQEAAwEBAAAAAAAAAAAAAAABAgMEBQb/xAAxEQEAAgIBAwIEBAYDAQEAAAAAAQIDEQQSITFBUQUTMmEicYGRQqGx0eHwFDPB8SP/2gAMAwEAAhEDEQA/ALszw5c45kEzCJmUTMyBzMhMygEwFJlQMwFJhCkwBIATIATAXMCZkAJlC5kTYQgZhAMoWBJQQYVCYCEygZhQzCgWlClpVLukQCYUuZCAJhSlpNAEwF3RoekzNSpmESBJlAOZYEEoOZQpMoUmELKJIhTAEgkgWADIFzAEIEIBMIEASoECSqEokBYUCYUhMBCZVKTKIDAhMihmApMgQmULmNCQPSZmlkGYQcy6BzMgJQcwITKgZgKYElQJQDMQpkEkCkyAUBrXaupHusRd711DeyL6t6Z7A8ntN1OPe8b8MopMsel19dudjcqcMpBVgfTB+hmN8N6eYSazDRNbBCYQIEgSVAMAYlEMKUyhSYCmFITKK2hSkygboUQYUCZApMoWAJQZB6KaWSS6BlElElBzCBmEAwJKBKgEwFJmMgZkFT3qMjJJVdzBVd9i/wAz7Qdg9zibK4b2jcQyik62z6zXLXUbgQwAG3BB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dNkMZZ2mSFzAmZAQYQ4MggMqGBhDCQNmAcwGWA4MB1kFiyKcSLpRqtMGIYcMOPqvcTVlruDW19NG2tO/XmauLeLRMfdfQ4E6kHECe3b0l8MomY8M+t1dlCN5Z+BvmU9PtM4z3x1mKz5Z1vLh6PxiyvJQDDdcjOeZI5F4lsnLMxp0l1e9LbnAHmH5R06Y/wCJhky9W7T6tNpTwzwJrcO3wr/L3MuLjzaNyw63Uv06VDaoA9v+ZtyRFe0G9s9dpU5HWY0vNJ3CqLTnkzGZmZ3Iy2SqzWSirMD2WZ5zcmYALTKAhmSFMygUvMoSWS5pthjLHaZshioJlQhMCZgEGQHMIbMIIMgeEEGA2YDKYFgkFiiQWrIyOIBkF1LgcHoes8/Pjtjt82n6qFle36HoZ14c1ckbg0WbgBKF1FIdSp7iY2jcES88+gIdaz0J6zVXvZZl000wexKV+VeT7zKI68kVa7S9fUorT7T1u1YYw8/q3LMSZw3nctlfDO0wVS5l0M9hlVlsmQqgew3TztNmwLRo2GZkm0MqkYzKBnsabIRktaZwksdhmyGKomVCEwJmBMwCDIhgYDqZENmEEGA8BlgXLMVWCQWCRRzCjmAwMgsW3HDcj+08/Lhtit14wWTHI5HrOvDnrkj7hBN4dRyMQirxbSYCv6GcmaJrO1N4NQAd3Uzp4Vf45a7T6O3faMYno2tDCXB1NmWPpOSzZTwzM0xZqXMqqHMooslFcaH/2Q=="
207
212
  style={
@@ -223,13 +228,16 @@ exports[`HotspotComponent renders snapshot with padding having a size accordingl
223
228
  <Layer>
224
229
  <WithStyles(RectComponent)
225
230
  disabled={false}
231
+ evaluateText={null}
226
232
  height={80}
227
233
  hotspotColor="#000"
228
234
  id="1"
229
235
  isEvaluateMode={false}
230
236
  key="1"
237
+ markAsCorrect={false}
231
238
  onClick={[MockFunction]}
232
239
  outlineColor="#FAFAFA"
240
+ scale={1}
233
241
  selected={true}
234
242
  strokeWidth={50}
235
243
  width={80}
@@ -0,0 +1,43 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Image snapshots image renders 1`] = `
4
+ <Group>
5
+ <Image
6
+ height={20}
7
+ image={null}
8
+ onMouseEnter={[Function]}
9
+ onMouseLeave={[Function]}
10
+ width={20}
11
+ x={5}
12
+ y={5}
13
+ />
14
+ </Group>
15
+ `;
16
+
17
+ exports[`Image snapshots tooltip renders 1`] = `
18
+ <Group>
19
+ <Image
20
+ height={20}
21
+ image={null}
22
+ onMouseEnter={[Function]}
23
+ onMouseLeave={[Function]}
24
+ width={20}
25
+ x={5}
26
+ y={5}
27
+ />
28
+ </Group>
29
+ `;
30
+
31
+ exports[`Image snapshots x y position renders 1`] = `
32
+ <Group>
33
+ <Image
34
+ height={20}
35
+ image={null}
36
+ onMouseEnter={[Function]}
37
+ onMouseLeave={[Function]}
38
+ width={20}
39
+ x={10}
40
+ y={10}
41
+ />
42
+ </Group>
43
+ `;
@@ -8,6 +8,8 @@ exports[`Polygon snapshots evaluate with correct answer renders 1`] = `
8
8
  }
9
9
  }
10
10
  disabled={false}
11
+ evaluateText="Correctly
12
+ selected"
11
13
  height={200}
12
14
  hotspotColor="rgba(137, 183, 244, 0.65)"
13
15
  id="1"
@@ -31,6 +33,7 @@ exports[`Polygon snapshots evaluate with correct answer renders 1`] = `
31
33
  },
32
34
  ]
33
35
  }
36
+ scale={1}
34
37
  selected={false}
35
38
  strokeWidth={5}
36
39
  />
@@ -44,6 +47,7 @@ exports[`Polygon snapshots hotspot color renders 1`] = `
44
47
  }
45
48
  }
46
49
  disabled={false}
50
+ evaluateText={null}
47
51
  height={200}
48
52
  hotspotColor="rgba(217, 30, 24, 0.65)"
49
53
  id="1"
@@ -67,6 +71,7 @@ exports[`Polygon snapshots hotspot color renders 1`] = `
67
71
  },
68
72
  ]
69
73
  }
74
+ scale={1}
70
75
  selected={false}
71
76
  strokeWidth={5}
72
77
  />
@@ -80,6 +85,7 @@ exports[`Polygon snapshots outline color renders 1`] = `
80
85
  }
81
86
  }
82
87
  disabled={false}
88
+ evaluateText={null}
83
89
  height={200}
84
90
  hotspotColor="rgba(137, 183, 244, 0.65)"
85
91
  id="1"
@@ -103,6 +109,7 @@ exports[`Polygon snapshots outline color renders 1`] = `
103
109
  },
104
110
  ]
105
111
  }
112
+ scale={1}
106
113
  selected={false}
107
114
  strokeWidth={5}
108
115
  />
@@ -116,6 +123,7 @@ exports[`Polygon snapshots outline width renders with default border width 1`] =
116
123
  }
117
124
  }
118
125
  disabled={false}
126
+ evaluateText={null}
119
127
  height={200}
120
128
  hotspotColor="rgba(137, 183, 244, 0.65)"
121
129
  id="1"
@@ -139,6 +147,7 @@ exports[`Polygon snapshots outline width renders with default border width 1`] =
139
147
  },
140
148
  ]
141
149
  }
150
+ scale={1}
142
151
  selected={false}
143
152
  strokeWidth={5}
144
153
  />
@@ -152,6 +161,7 @@ exports[`Polygon snapshots outline width renders with given border width 1`] = `
152
161
  }
153
162
  }
154
163
  disabled={false}
164
+ evaluateText={null}
155
165
  height={200}
156
166
  hotspotColor="rgba(137, 183, 244, 0.65)"
157
167
  id="1"
@@ -175,6 +185,7 @@ exports[`Polygon snapshots outline width renders with given border width 1`] = `
175
185
  },
176
186
  ]
177
187
  }
188
+ scale={1}
178
189
  selected={false}
179
190
  strokeWidth={10}
180
191
  />
@@ -8,6 +8,8 @@ exports[`Rectangle snapshots evaluate with correct answer renders 1`] = `
8
8
  }
9
9
  }
10
10
  disabled={false}
11
+ evaluateText="Correctly
12
+ selected"
11
13
  height={200}
12
14
  hotspotColor="rgba(137, 183, 244, 0.65)"
13
15
  id="1"
@@ -15,6 +17,7 @@ exports[`Rectangle snapshots evaluate with correct answer renders 1`] = `
15
17
  isEvaluateMode={true}
16
18
  onClick={[MockFunction]}
17
19
  outlineColor="blue"
20
+ scale={1}
18
21
  selected={false}
19
22
  strokeWidth={5}
20
23
  width={300}
@@ -31,6 +34,7 @@ exports[`Rectangle snapshots hotspot color renders 1`] = `
31
34
  }
32
35
  }
33
36
  disabled={false}
37
+ evaluateText={null}
34
38
  height={200}
35
39
  hotspotColor="rgba(217, 30, 24, 0.65)"
36
40
  id="1"
@@ -38,6 +42,7 @@ exports[`Rectangle snapshots hotspot color renders 1`] = `
38
42
  isEvaluateMode={false}
39
43
  onClick={[MockFunction]}
40
44
  outlineColor="blue"
45
+ scale={1}
41
46
  selected={false}
42
47
  strokeWidth={5}
43
48
  width={300}
@@ -54,6 +59,7 @@ exports[`Rectangle snapshots outline color renders 1`] = `
54
59
  }
55
60
  }
56
61
  disabled={false}
62
+ evaluateText={null}
57
63
  height={200}
58
64
  hotspotColor="rgba(137, 183, 244, 0.65)"
59
65
  id="1"
@@ -61,6 +67,7 @@ exports[`Rectangle snapshots outline color renders 1`] = `
61
67
  isEvaluateMode={false}
62
68
  onClick={[MockFunction]}
63
69
  outlineColor="red"
70
+ scale={1}
64
71
  selected={false}
65
72
  strokeWidth={5}
66
73
  width={300}
@@ -77,6 +84,7 @@ exports[`Rectangle snapshots outline width renders with default border width 1`]
77
84
  }
78
85
  }
79
86
  disabled={false}
87
+ evaluateText={null}
80
88
  height={200}
81
89
  hotspotColor="rgba(137, 183, 244, 0.65)"
82
90
  id="1"
@@ -84,6 +92,7 @@ exports[`Rectangle snapshots outline width renders with default border width 1`]
84
92
  isEvaluateMode={false}
85
93
  onClick={[MockFunction]}
86
94
  outlineColor="blue"
95
+ scale={1}
87
96
  selected={false}
88
97
  strokeWidth={5}
89
98
  width={300}
@@ -100,6 +109,7 @@ exports[`Rectangle snapshots outline width renders with given border width 1`] =
100
109
  }
101
110
  }
102
111
  disabled={false}
112
+ evaluateText={null}
103
113
  height={200}
104
114
  hotspotColor="rgba(137, 183, 244, 0.65)"
105
115
  id="1"
@@ -107,6 +117,7 @@ exports[`Rectangle snapshots outline width renders with given border width 1`] =
107
117
  isEvaluateMode={false}
108
118
  onClick={[MockFunction]}
109
119
  outlineColor="blue"
120
+ scale={1}
110
121
  selected={false}
111
122
  strokeWidth={10}
112
123
  width={300}
@@ -4,9 +4,18 @@ import { shallow } from 'enzyme';
4
4
  import toJson from 'enzyme-to-json';
5
5
  import Konva from 'konva';
6
6
 
7
+ import { shallowChild } from '@pie-lib/test-utils';
8
+ import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';
9
+
7
10
  import Container, { Container as ContainerComp } from '../hotspot/container';
8
11
  import HotspotComponent from '../hotspot/index';
9
12
 
13
+ global.MutationObserver = class {
14
+ constructor(callback) {}
15
+ disconnect() {}
16
+ observe(element, initObject) {}
17
+ };
18
+
10
19
  Konva.isBrowser = false;
11
20
 
12
21
  describe('HotspotComponent', () => {
@@ -61,6 +70,54 @@ describe('HotspotComponent', () => {
61
70
  });
62
71
  });
63
72
 
73
+ describe('CorrectAnswerToggle', () => {
74
+ let testWrapper, component, toggle;
75
+ const model = {
76
+ mode: 'evaluate',
77
+ responseCorrect: false,
78
+ };
79
+ const testWrapperFn = (props) => shallowChild(HotspotComponent, {
80
+ model: {
81
+ ...model,
82
+ ...props
83
+ }
84
+ }, 1);
85
+
86
+ beforeEach(() => {
87
+ testWrapper = testWrapperFn({});
88
+ component = testWrapper();
89
+ toggle = component.find(CorrectAnswerToggle);
90
+ });
91
+
92
+ it('renders when the mode is evaluate and the response is incorrect', () => {
93
+ expect(toggle.length).toEqual(1);
94
+ expect(toggle.prop('show')).toEqual(true);
95
+ });
96
+
97
+ it('does not render outside of evaluate mode', () => {
98
+ const tw = testWrapperFn({ mode: 'gather' });
99
+ const c = tw();
100
+ const t = c.find(CorrectAnswerToggle);
101
+ expect(t.length).toEqual(0);
102
+ });
103
+
104
+ it('does not render if the response is correct', () => {
105
+ const tw = testWrapperFn({ responseCorrect: true });
106
+ const c = tw();
107
+ const t = c.find(CorrectAnswerToggle);
108
+ expect(t.length).toEqual(0);
109
+ });
110
+
111
+ it('toggles the state', () => {
112
+ component.setState({ showCorrect: false });
113
+ expect(component.state('showCorrect')).toEqual(false);
114
+ expect(toggle.prop('toggled')).toEqual(false);
115
+ component.instance().onToggle();
116
+ expect(component.state('showCorrect')).toEqual(true);
117
+ expect(component.find(CorrectAnswerToggle).prop('toggled')).toEqual(true);
118
+ });
119
+ });
120
+
64
121
  describe('Container', () => {
65
122
  let onSelectChoice, wrapper;
66
123
 
File without changes
@@ -0,0 +1,224 @@
1
+ import React from 'react';
2
+ import _ from 'lodash';
3
+ import { shallow } from 'enzyme';
4
+ import toJson from 'enzyme-to-json';
5
+ import Konva from 'konva';
6
+ import { Line } from 'react-konva';
7
+
8
+ import { shallowChild } from '@pie-lib/test-utils';
9
+
10
+ import Polygon from '../hotspot/polygon';
11
+ import Image from '../hotspot/image';
12
+ import { faCorrect, faWrong } from '../hotspot/icons';
13
+
14
+ Konva.isBrowser = false;
15
+
16
+ describe('Polygon', () => {
17
+ let onClick, wrapper;
18
+
19
+ const mkWrapper = (opts = {}) => {
20
+ opts = _.extend(
21
+ {
22
+ classes: {
23
+ base: 'base'
24
+ },
25
+ height: 200,
26
+ hotspotColor: 'rgba(137, 183, 244, 0.65)',
27
+ id: '1',
28
+ isCorrect: false,
29
+ isEvaluateMode: false,
30
+ evaluateText: null,
31
+ disabled: false,
32
+ outlineColor: 'blue',
33
+ selected: false,
34
+ points: [{ x: 94, y: 4 }, { x: 89, y: 4 }, { x: 36, y: 40 }]
35
+ },
36
+ opts
37
+ );
38
+
39
+ return shallow(<Polygon {...opts} onClick={onClick} />);
40
+ };
41
+
42
+ beforeEach(() => {
43
+ onClick = jest.fn();
44
+ wrapper = mkWrapper();
45
+ });
46
+
47
+ describe('snapshots', () => {
48
+ describe('outline color', () => {
49
+ it('renders', () => {
50
+ const wrapper = mkWrapper({ outlineColor: 'red' });
51
+ expect(toJson(wrapper)).toMatchSnapshot();
52
+ });
53
+ });
54
+
55
+ describe('outline width', () => {
56
+ it('renders with default border width', () => {
57
+ const wrapper = mkWrapper();
58
+ expect(toJson(wrapper)).toMatchSnapshot();
59
+ });
60
+
61
+ it('renders with given border width', () => {
62
+ const wrapper = mkWrapper({ strokeWidth: 10 });
63
+ expect(toJson(wrapper)).toMatchSnapshot();
64
+ });
65
+ });
66
+
67
+
68
+ describe('hotspot color', () => {
69
+ it('renders', () => {
70
+ const wrapper = mkWrapper({ hotspotColor: 'rgba(217, 30, 24, 0.65)' });
71
+ expect(toJson(wrapper)).toMatchSnapshot();
72
+ });
73
+ });
74
+
75
+ describe('evaluate with correct answer', () => {
76
+ it('renders', () => {
77
+ const wrapper = mkWrapper({ isEvaluateMode: true, isCorrect: true, evaluateText: 'Correctly\nselected' });
78
+ expect(toJson(wrapper)).toMatchSnapshot();
79
+ });
80
+ });
81
+ });
82
+
83
+ describe('in evaluate mode', () => {
84
+ const defaultModel = {
85
+ height: 200,
86
+ hotspotColor: 'rgba(137, 183, 244, 0.65)',
87
+ id: '1',
88
+ isCorrect: false,
89
+ isEvaluateMode: true,
90
+ evaluateText: null,
91
+ disabled: true,
92
+ outlineColor: 'blue',
93
+ strokeWidth: 5,
94
+ selected: false,
95
+ points: [{ x: 94, y: 4 }, { x: 89, y: 4 }, { x: 36, y: 40 }],
96
+ markAsCorrect: false,
97
+ showCorrectEnabled: false,
98
+ onClick
99
+ };
100
+
101
+ const getComponents = (model) => {
102
+ const testWrapper = shallowChild(Polygon, {
103
+ ...defaultModel,
104
+ ...model
105
+ }, 1);
106
+ const polygonComponent = testWrapper();
107
+ const lineComponent = polygonComponent.find(Line);
108
+ return {
109
+ polygonComponent,
110
+ lineComponent
111
+ };
112
+ }
113
+
114
+ describe('when correctly selected', () => {
115
+ const { polygonComponent, lineComponent } = getComponents({
116
+ selected: true,
117
+ isCorrect: true
118
+ });
119
+
120
+ it('should have a blue outline', () => {
121
+ expect(lineComponent.prop('stroke')).toEqual('blue');
122
+ expect(lineComponent.prop('strokeWidth')).toEqual(defaultModel.strokeWidth);
123
+ });
124
+
125
+ it('should have a green checkmark icon', () => {
126
+ const imgComponent = polygonComponent.find(Image);
127
+ expect(imgComponent.length).toEqual(1);
128
+ expect(imgComponent.prop('src')).toEqual(faCorrect);
129
+ });
130
+ });
131
+
132
+ describe('when correctly not selected', () => {
133
+ const { polygonComponent, lineComponent } = getComponents({
134
+ selected: false,
135
+ isCorrect: true
136
+ });
137
+
138
+ it('should have no outline', () => {
139
+ expect(lineComponent.prop('strokeWidth')).toEqual(0);
140
+ });
141
+
142
+ it('should have no icon', () => {
143
+ const imgComponent = polygonComponent.find(Image);
144
+ expect(imgComponent.length).toEqual(0);
145
+ });
146
+ });
147
+
148
+ describe('when incorrectly selected', () => {
149
+ const { polygonComponent, lineComponent } = getComponents({
150
+ selected: true,
151
+ isCorrect: false
152
+ });
153
+
154
+ it('should have a red outline', () => {
155
+ expect(lineComponent.prop('stroke')).toEqual('red');
156
+ expect(lineComponent.prop('strokeWidth')).toEqual(defaultModel.strokeWidth);
157
+ });
158
+
159
+ it('should have a red x icon', () => {
160
+ const imgComponent = polygonComponent.find(Image);
161
+ expect(imgComponent.length).toEqual(1);
162
+ expect(imgComponent.prop('src')).toEqual(faWrong);
163
+ });
164
+ });
165
+
166
+ describe('when incorrectly not selected', () => {
167
+ const { polygonComponent, lineComponent } = getComponents({
168
+ selected: false,
169
+ isCorrect: false
170
+ });
171
+
172
+ it('should have no outline', () => {
173
+ expect(lineComponent.prop('strokeWidth')).toEqual(0);
174
+ });
175
+
176
+ it('should have a red x icon', () => {
177
+ const imgComponent = polygonComponent.find(Image);
178
+ expect(imgComponent.length).toEqual(1);
179
+ expect(imgComponent.prop('src')).toEqual(faWrong);
180
+ });
181
+ });
182
+
183
+ describe('when showing correct answer (showCorrectEnabled = true)', () => {
184
+ it('should have a green outline', () => {
185
+ const { lineComponent } = getComponents({
186
+ showCorrectEnabled: true,
187
+ markAsCorrect: true
188
+ });
189
+ expect(lineComponent.prop('stroke')).toEqual('green');
190
+ expect(lineComponent.prop('strokeWidth')).toEqual(defaultModel.strokeWidth);
191
+ });
192
+
193
+ it('should have a green checkmark icon', () => {
194
+ const { polygonComponent } = getComponents({
195
+ showCorrectEnabled: true,
196
+ markAsCorrect: true
197
+ });
198
+ const imgComponent = polygonComponent.find(Image);
199
+ expect(imgComponent.prop('src')).toEqual(faCorrect);
200
+ });
201
+
202
+ it('should not be selected if the answer is incorrect', () => {
203
+ const { lineComponent } = getComponents({
204
+ showCorrectEnabled: true,
205
+ markAsCorrect: false,
206
+ selected: true,
207
+ isCorrect: false
208
+ });
209
+ expect(lineComponent.prop('strokeWidth')).toEqual(0);
210
+ });
211
+
212
+ it('should not render an icon if the answer is incorrect', () => {
213
+ const { polygonComponent } = getComponents({
214
+ showCorrectEnabled: true,
215
+ markAsCorrect: false,
216
+ selected: true,
217
+ isCorrect: false
218
+ });
219
+ const imgComponent = polygonComponent.find(Image);
220
+ expect(imgComponent.length).toEqual(0);
221
+ });
222
+ });
223
+ });
224
+ });