@pie-element/hotspot 4.7.18-next.85 → 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 +485 -0
- package/configure/CHANGELOG.md +425 -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 +72 -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,48 +3,45 @@ import ReactDOM from 'react-dom';
|
|
|
3
3
|
|
|
4
4
|
jest.mock('@pie-lib/config-ui', () => ({
|
|
5
5
|
choiceUtils: {
|
|
6
|
-
firstAvailableIndex: jest.fn()
|
|
6
|
+
firstAvailableIndex: jest.fn(),
|
|
7
7
|
},
|
|
8
8
|
settings: {
|
|
9
|
-
Panel: props => <div {...props} />,
|
|
9
|
+
Panel: (props) => <div {...props} />,
|
|
10
10
|
toggle: jest.fn(),
|
|
11
|
-
radio: jest.fn()
|
|
12
|
-
}
|
|
11
|
+
radio: jest.fn(),
|
|
12
|
+
},
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
15
|
jest.mock('react-dom', () => ({
|
|
16
|
-
render: jest.fn()
|
|
16
|
+
render: jest.fn(),
|
|
17
17
|
}));
|
|
18
18
|
|
|
19
19
|
const model = () => ({
|
|
20
20
|
prompt: 'This is the question prompt',
|
|
21
21
|
imageUrl: '',
|
|
22
22
|
shapes: {
|
|
23
|
-
rectangles: [
|
|
24
|
-
{ id: '1', correct: true },
|
|
25
|
-
{ id: '2' },
|
|
26
|
-
{ id: '3' }
|
|
27
|
-
],
|
|
23
|
+
rectangles: [{ id: '1', correct: true }, { id: '2' }, { id: '3' }],
|
|
28
24
|
polygons: [
|
|
29
25
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
points: [
|
|
27
|
+
{ x: 1, y: 2 },
|
|
28
|
+
{ y: 139, x: 1 },
|
|
29
|
+
{ y: 139, x: 130 },
|
|
30
|
+
{ x: 130, y: 2 },
|
|
31
|
+
],
|
|
32
|
+
correct: false,
|
|
33
|
+
id: '0',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
35
36
|
},
|
|
36
37
|
dimensions: { height: 0, width: 0 },
|
|
37
38
|
hotspotColor: 'rgba(137, 183, 244, 0.65)',
|
|
38
|
-
hotspotList: [
|
|
39
|
-
'rgba(137, 183, 244, 0.65)',
|
|
40
|
-
'rgba(217, 30, 24, 0.65)',
|
|
41
|
-
'rgba(254, 241, 96, 0.65)'
|
|
42
|
-
],
|
|
39
|
+
hotspotList: ['rgba(137, 183, 244, 0.65)', 'rgba(217, 30, 24, 0.65)', 'rgba(254, 241, 96, 0.65)'],
|
|
43
40
|
outlineColor: 'blue',
|
|
44
41
|
outlineList: ['blue', 'red', 'yellow'],
|
|
45
42
|
configure: {},
|
|
46
43
|
multipleCorrect: true,
|
|
47
|
-
partialScoring: false
|
|
44
|
+
partialScoring: false,
|
|
48
45
|
});
|
|
49
46
|
|
|
50
47
|
describe('index', () => {
|
|
@@ -74,16 +71,12 @@ describe('index', () => {
|
|
|
74
71
|
it('changes partial scoring value', () => {
|
|
75
72
|
el.onModelChangedByConfig({ ...initialModel, partialScoring: true });
|
|
76
73
|
|
|
77
|
-
expect(onModelChanged).toBeCalledWith(
|
|
78
|
-
expect.objectContaining({ partialScoring: true }),
|
|
79
|
-
);
|
|
74
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ partialScoring: true }));
|
|
80
75
|
});
|
|
81
76
|
it('changes multiple correct value', () => {
|
|
82
77
|
el.onModelChangedByConfig({ ...initialModel, multipleCorrect: false });
|
|
83
78
|
|
|
84
|
-
expect(onModelChanged).toBeCalledWith(
|
|
85
|
-
expect.objectContaining({ multipleCorrect: false }),
|
|
86
|
-
);
|
|
79
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ multipleCorrect: false }));
|
|
87
80
|
});
|
|
88
81
|
});
|
|
89
82
|
|
|
@@ -91,17 +84,13 @@ describe('index', () => {
|
|
|
91
84
|
it('changes hotspot color', () => {
|
|
92
85
|
el.onColorChanged('hotspotColor', 'red');
|
|
93
86
|
|
|
94
|
-
expect(onModelChanged).toBeCalledWith(
|
|
95
|
-
expect.objectContaining({ hotspotColor: 'red' }),
|
|
96
|
-
);
|
|
87
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ hotspotColor: 'red' }));
|
|
97
88
|
});
|
|
98
89
|
|
|
99
90
|
it('changes outline color', () => {
|
|
100
91
|
el.onColorChanged('outlineColor', 'lightred');
|
|
101
92
|
|
|
102
|
-
expect(onModelChanged).toBeCalledWith(
|
|
103
|
-
expect.objectContaining({ outlineColor: 'lightred' }),
|
|
104
|
-
);
|
|
93
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ outlineColor: 'lightred' }));
|
|
105
94
|
});
|
|
106
95
|
});
|
|
107
96
|
|
|
@@ -110,9 +99,7 @@ describe('index', () => {
|
|
|
110
99
|
const newPrompt = 'This is the second question prompt';
|
|
111
100
|
el.onPromptChanged(newPrompt);
|
|
112
101
|
|
|
113
|
-
expect(onModelChanged).toBeCalledWith(
|
|
114
|
-
expect.objectContaining({ prompt: newPrompt }),
|
|
115
|
-
);
|
|
102
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ prompt: newPrompt }));
|
|
116
103
|
});
|
|
117
104
|
});
|
|
118
105
|
|
|
@@ -121,9 +108,7 @@ describe('index', () => {
|
|
|
121
108
|
const newRationale = 'New Rationale';
|
|
122
109
|
el.onRationaleChanged(newRationale);
|
|
123
110
|
|
|
124
|
-
expect(onModelChanged).toBeCalledWith(
|
|
125
|
-
expect.objectContaining({ rationale: newRationale }),
|
|
126
|
-
);
|
|
111
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ rationale: newRationale }));
|
|
127
112
|
});
|
|
128
113
|
});
|
|
129
114
|
|
|
@@ -132,9 +117,7 @@ describe('index', () => {
|
|
|
132
117
|
const newTeacherInstructions = 'New Teacher Instructions';
|
|
133
118
|
el.onTeacherInstructionsChanged(newTeacherInstructions);
|
|
134
119
|
|
|
135
|
-
expect(onModelChanged).toBeCalledWith(
|
|
136
|
-
expect.objectContaining({ teacherInstructions: newTeacherInstructions }),
|
|
137
|
-
);
|
|
120
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ teacherInstructions: newTeacherInstructions }));
|
|
138
121
|
});
|
|
139
122
|
});
|
|
140
123
|
|
|
@@ -142,9 +125,7 @@ describe('index', () => {
|
|
|
142
125
|
it('changes the image dimensions', () => {
|
|
143
126
|
el.onUpdateImageDimension({ height: 400, width: 400 });
|
|
144
127
|
|
|
145
|
-
expect(onModelChanged).toBeCalledWith(
|
|
146
|
-
expect.objectContaining({ dimensions: { height: 400, width: 400 } })
|
|
147
|
-
);
|
|
128
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ dimensions: { height: 400, width: 400 } }));
|
|
148
129
|
});
|
|
149
130
|
});
|
|
150
131
|
|
|
@@ -153,9 +134,7 @@ describe('index', () => {
|
|
|
153
134
|
const shapes = { polygons: [], rectangles: [...initialModel.shapes.rectangles, { id: '2' }] };
|
|
154
135
|
el.onUpdateShapes(shapes);
|
|
155
136
|
|
|
156
|
-
expect(onModelChanged).toBeCalledWith(
|
|
157
|
-
expect.objectContaining({ shapes }),
|
|
158
|
-
);
|
|
137
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ shapes }));
|
|
159
138
|
});
|
|
160
139
|
|
|
161
140
|
it('removes the latest shape', () => {
|
|
@@ -171,9 +150,7 @@ describe('index', () => {
|
|
|
171
150
|
it('removes all shapes', () => {
|
|
172
151
|
el.onUpdateShapes({ polygons: [], rectangles: [] });
|
|
173
152
|
|
|
174
|
-
expect(onModelChanged).toBeCalledWith(
|
|
175
|
-
expect.objectContaining({ shapes: { polygons: [], rectangles: [] } }),
|
|
176
|
-
);
|
|
153
|
+
expect(onModelChanged).toBeCalledWith(expect.objectContaining({ shapes: { polygons: [], rectangles: [] } }));
|
|
177
154
|
});
|
|
178
155
|
});
|
|
179
156
|
|
|
@@ -5,16 +5,16 @@ import defaultValues from '../defaults';
|
|
|
5
5
|
|
|
6
6
|
jest.mock('@pie-lib/config-ui', () => ({
|
|
7
7
|
choiceUtils: {
|
|
8
|
-
firstAvailableIndex: jest.fn()
|
|
8
|
+
firstAvailableIndex: jest.fn(),
|
|
9
9
|
},
|
|
10
10
|
settings: {
|
|
11
|
-
Panel: props => <div {...props} />,
|
|
11
|
+
Panel: (props) => <div {...props} />,
|
|
12
12
|
toggle: jest.fn(),
|
|
13
|
-
radio: jest.fn()
|
|
13
|
+
radio: jest.fn(),
|
|
14
14
|
},
|
|
15
15
|
layout: {
|
|
16
|
-
ConfigLayout: ({ children }) => <div>{children}</div
|
|
17
|
-
}
|
|
16
|
+
ConfigLayout: ({ children }) => <div>{children}</div>,
|
|
17
|
+
},
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
20
|
const model = () => ({
|
|
@@ -28,44 +28,62 @@ const model = () => ({
|
|
|
28
28
|
width: 130,
|
|
29
29
|
x: 1,
|
|
30
30
|
y: 1,
|
|
31
|
-
correct: true
|
|
32
|
-
},
|
|
31
|
+
correct: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
33
34
|
id: '1',
|
|
34
35
|
height: 140,
|
|
35
36
|
width: 130,
|
|
36
37
|
x: 140,
|
|
37
|
-
y: 1
|
|
38
|
-
},
|
|
38
|
+
y: 1,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
39
41
|
id: '2',
|
|
40
42
|
height: 140,
|
|
41
43
|
width: 130,
|
|
42
44
|
x: 280,
|
|
43
|
-
y: 1
|
|
44
|
-
}
|
|
45
|
+
y: 1,
|
|
46
|
+
},
|
|
45
47
|
],
|
|
46
48
|
polygons: [
|
|
47
49
|
{
|
|
48
|
-
points: [
|
|
50
|
+
points: [
|
|
51
|
+
{ x: 1, y: 148 },
|
|
52
|
+
{ x: 1, y: 288 },
|
|
53
|
+
{ y: 288, x: 129 },
|
|
54
|
+
{ y: 148, x: 129 },
|
|
55
|
+
],
|
|
49
56
|
correct: true,
|
|
50
|
-
id: '3'
|
|
51
|
-
},
|
|
57
|
+
id: '3',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
52
60
|
id: '4',
|
|
53
|
-
points: [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
x:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
+
points: [
|
|
62
|
+
{ y: 151, x: 141 },
|
|
63
|
+
{ y: 289, x: 141 },
|
|
64
|
+
{ y: 289, x: 269 },
|
|
65
|
+
{ x: 269, y: 151 },
|
|
66
|
+
],
|
|
67
|
+
correct: false,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
points: [
|
|
71
|
+
{ x: 279, y: 149.99999999999997 },
|
|
72
|
+
{ x: 279, y: 289 },
|
|
73
|
+
{ x: 407, y: 289 },
|
|
74
|
+
{
|
|
75
|
+
x: 407,
|
|
76
|
+
y: 149.99999999999997,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
correct: false,
|
|
80
|
+
id: '5',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
61
83
|
},
|
|
62
84
|
dimensions: { height: 300, width: 400 },
|
|
63
85
|
hotspotColor: 'rgba(137, 183, 244, 0.65)',
|
|
64
|
-
hotspotList: [
|
|
65
|
-
'rgba(137, 183, 244, 0.65)',
|
|
66
|
-
'rgba(217, 30, 24, 0.65)',
|
|
67
|
-
'rgba(254, 241, 96, 0.65)'
|
|
68
|
-
],
|
|
86
|
+
hotspotList: ['rgba(137, 183, 244, 0.65)', 'rgba(217, 30, 24, 0.65)', 'rgba(254, 241, 96, 0.65)'],
|
|
69
87
|
outlineColor: 'blue',
|
|
70
88
|
outlineList: ['blue', 'red', 'yellow'],
|
|
71
89
|
configure: {},
|
|
@@ -85,11 +103,12 @@ describe('Root', () => {
|
|
|
85
103
|
};
|
|
86
104
|
|
|
87
105
|
expect(shallow(<Root {...props} />)).toMatchSnapshot();
|
|
88
|
-
})
|
|
106
|
+
});
|
|
89
107
|
});
|
|
90
108
|
|
|
91
109
|
describe('logic', () => {
|
|
92
|
-
let w,
|
|
110
|
+
let w,
|
|
111
|
+
onColorChanged = jest.fn();
|
|
93
112
|
|
|
94
113
|
beforeEach(() => {
|
|
95
114
|
w = (config, onUpdateImageDimension, onUpdateShapes) => {
|
|
@@ -101,10 +120,16 @@ describe('Root', () => {
|
|
|
101
120
|
dimensions: { width: 200, height: 300 },
|
|
102
121
|
shapes: {
|
|
103
122
|
rectangles: [{ x: 10, y: 10, height: 100, width: 100 }],
|
|
104
|
-
polygons: [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
123
|
+
polygons: [
|
|
124
|
+
{
|
|
125
|
+
points: [
|
|
126
|
+
{ x: 0, y: 200 },
|
|
127
|
+
{ x: 200, y: 200 },
|
|
128
|
+
{ x: 100, y: 300 },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
108
133
|
},
|
|
109
134
|
onColorChanged,
|
|
110
135
|
onUpdateImageDimension,
|
|
@@ -112,7 +137,7 @@ describe('Root', () => {
|
|
|
112
137
|
};
|
|
113
138
|
|
|
114
139
|
return shallow(<Root {...props} />);
|
|
115
|
-
}
|
|
140
|
+
};
|
|
116
141
|
});
|
|
117
142
|
|
|
118
143
|
describe('handleColorChange', () => {
|
|
@@ -138,13 +163,20 @@ describe('Root', () => {
|
|
|
138
163
|
|
|
139
164
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
140
165
|
width: 400,
|
|
141
|
-
height: 600
|
|
166
|
+
height: 600,
|
|
142
167
|
});
|
|
143
168
|
expect(onUpdateShapes).toBeCalledWith({
|
|
144
169
|
rectangles: [{ x: 20, y: 20, height: 200, width: 200, index: 0 }],
|
|
145
|
-
polygons: [
|
|
146
|
-
|
|
147
|
-
|
|
170
|
+
polygons: [
|
|
171
|
+
{
|
|
172
|
+
points: [
|
|
173
|
+
{ x: 0, y: 400 },
|
|
174
|
+
{ x: 400, y: 400 },
|
|
175
|
+
{ x: 200, y: 600 },
|
|
176
|
+
],
|
|
177
|
+
index: 1,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
148
180
|
});
|
|
149
181
|
});
|
|
150
182
|
|
|
@@ -153,13 +185,20 @@ describe('Root', () => {
|
|
|
153
185
|
|
|
154
186
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
155
187
|
width: 100,
|
|
156
|
-
height: 150
|
|
188
|
+
height: 150,
|
|
157
189
|
});
|
|
158
190
|
expect(onUpdateShapes).toBeCalledWith({
|
|
159
191
|
rectangles: [{ x: 5, y: 5, height: 50, width: 50, index: 0 }],
|
|
160
|
-
polygons: [
|
|
161
|
-
|
|
162
|
-
|
|
192
|
+
polygons: [
|
|
193
|
+
{
|
|
194
|
+
points: [
|
|
195
|
+
{ x: 0, y: 100 },
|
|
196
|
+
{ x: 100, y: 100 },
|
|
197
|
+
{ x: 50, y: 150 },
|
|
198
|
+
],
|
|
199
|
+
index: 1,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
163
202
|
});
|
|
164
203
|
});
|
|
165
204
|
|
|
@@ -168,13 +207,20 @@ describe('Root', () => {
|
|
|
168
207
|
|
|
169
208
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
170
209
|
width: 300,
|
|
171
|
-
height: 450
|
|
210
|
+
height: 450,
|
|
172
211
|
});
|
|
173
212
|
expect(onUpdateShapes).toBeCalledWith({
|
|
174
213
|
rectangles: [{ x: 15, y: 15, height: 150, width: 150, index: 0 }],
|
|
175
|
-
polygons: [
|
|
176
|
-
|
|
177
|
-
|
|
214
|
+
polygons: [
|
|
215
|
+
{
|
|
216
|
+
points: [
|
|
217
|
+
{ x: 0, y: 300 },
|
|
218
|
+
{ x: 300, y: 300 },
|
|
219
|
+
{ x: 150, y: 450 },
|
|
220
|
+
],
|
|
221
|
+
index: 1,
|
|
222
|
+
},
|
|
223
|
+
],
|
|
178
224
|
});
|
|
179
225
|
});
|
|
180
226
|
|
|
@@ -183,13 +229,20 @@ describe('Root', () => {
|
|
|
183
229
|
|
|
184
230
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
185
231
|
width: 180,
|
|
186
|
-
height: 270
|
|
232
|
+
height: 270,
|
|
187
233
|
});
|
|
188
234
|
expect(onUpdateShapes).toBeCalledWith({
|
|
189
235
|
rectangles: [{ x: 9, y: 9, height: 90, width: 90, index: 0 }],
|
|
190
|
-
polygons: [
|
|
191
|
-
|
|
192
|
-
|
|
236
|
+
polygons: [
|
|
237
|
+
{
|
|
238
|
+
points: [
|
|
239
|
+
{ x: 0, y: 180 },
|
|
240
|
+
{ x: 180, y: 180 },
|
|
241
|
+
{ x: 90, y: 270 },
|
|
242
|
+
],
|
|
243
|
+
index: 1,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
193
246
|
});
|
|
194
247
|
});
|
|
195
248
|
});
|
|
@@ -200,12 +253,16 @@ describe('Root', () => {
|
|
|
200
253
|
let onUpdateShapes = jest.fn();
|
|
201
254
|
|
|
202
255
|
beforeEach(() => {
|
|
203
|
-
wrapper = w(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
256
|
+
wrapper = w(
|
|
257
|
+
{
|
|
258
|
+
...defaultValues.configuration,
|
|
259
|
+
preserveAspectRatio: {
|
|
260
|
+
enabled: false,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
onUpdateImageDimension,
|
|
264
|
+
onUpdateShapes,
|
|
265
|
+
);
|
|
209
266
|
});
|
|
210
267
|
|
|
211
268
|
it('increase width with 100%:', () => {
|
|
@@ -213,13 +270,20 @@ describe('Root', () => {
|
|
|
213
270
|
|
|
214
271
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
215
272
|
width: 400,
|
|
216
|
-
height: 300
|
|
273
|
+
height: 300,
|
|
217
274
|
});
|
|
218
275
|
expect(onUpdateShapes).toBeCalledWith({
|
|
219
276
|
rectangles: [{ x: 20, y: 10, height: 100, width: 200, index: 0 }],
|
|
220
|
-
polygons: [
|
|
221
|
-
|
|
222
|
-
|
|
277
|
+
polygons: [
|
|
278
|
+
{
|
|
279
|
+
points: [
|
|
280
|
+
{ x: 0, y: 200 },
|
|
281
|
+
{ x: 400, y: 200 },
|
|
282
|
+
{ x: 200, y: 300 },
|
|
283
|
+
],
|
|
284
|
+
index: 1,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
223
287
|
});
|
|
224
288
|
});
|
|
225
289
|
|
|
@@ -228,15 +292,21 @@ describe('Root', () => {
|
|
|
228
292
|
|
|
229
293
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
230
294
|
width: 100,
|
|
231
|
-
height: 300
|
|
295
|
+
height: 300,
|
|
232
296
|
});
|
|
233
297
|
expect(onUpdateShapes).toBeCalledWith({
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
298
|
+
rectangles: [{ x: 5, y: 10, height: 100, width: 50, index: 0 }],
|
|
299
|
+
polygons: [
|
|
300
|
+
{
|
|
301
|
+
points: [
|
|
302
|
+
{ x: 0, y: 200 },
|
|
303
|
+
{ x: 100, y: 200 },
|
|
304
|
+
{ x: 50, y: 300 },
|
|
305
|
+
],
|
|
306
|
+
index: 1,
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
});
|
|
240
310
|
});
|
|
241
311
|
|
|
242
312
|
it('increase height with 50%:', () => {
|
|
@@ -244,16 +314,21 @@ describe('Root', () => {
|
|
|
244
314
|
|
|
245
315
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
246
316
|
width: 200,
|
|
247
|
-
height: 450
|
|
317
|
+
height: 450,
|
|
248
318
|
});
|
|
249
319
|
expect(onUpdateShapes).toBeCalledWith({
|
|
250
|
-
|
|
251
|
-
|
|
320
|
+
rectangles: [{ x: 10, y: 15, height: 150, width: 100, index: 0 }],
|
|
321
|
+
polygons: [
|
|
322
|
+
{
|
|
252
323
|
index: 1,
|
|
253
|
-
points: [
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
324
|
+
points: [
|
|
325
|
+
{ x: 0, y: 300 },
|
|
326
|
+
{ x: 200, y: 300 },
|
|
327
|
+
{ x: 100, y: 450 },
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
});
|
|
257
332
|
});
|
|
258
333
|
|
|
259
334
|
it('decrease height with 10%', () => {
|
|
@@ -261,16 +336,21 @@ describe('Root', () => {
|
|
|
261
336
|
|
|
262
337
|
expect(onUpdateImageDimension).toBeCalledWith({
|
|
263
338
|
width: 200,
|
|
264
|
-
height: 270
|
|
339
|
+
height: 270,
|
|
265
340
|
});
|
|
266
341
|
expect(onUpdateShapes).toBeCalledWith({
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
342
|
+
rectangles: [{ x: 10, y: 9, height: 90, width: 100, index: 0 }],
|
|
343
|
+
polygons: [
|
|
344
|
+
{
|
|
345
|
+
points: [
|
|
346
|
+
{ x: 0, y: 180 },
|
|
347
|
+
{ x: 200, y: 180 },
|
|
348
|
+
{ x: 100, y: 270 },
|
|
349
|
+
],
|
|
350
|
+
index: 1,
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
});
|
|
274
354
|
});
|
|
275
355
|
});
|
|
276
356
|
});
|