Skip to content

Commit 772762e

Browse files
committed
feat(hotspot): add tests for delete functionality pd-597
1 parent 620b9a6 commit 772762e

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

packages/hotspot/configure/src/__tests__/hotspot-container.test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe('HotspotContainer', () => {
7878
let w,
7979
onImageUpload = jest.fn(),
8080
onUpdateImageDimension = jest.fn(),
81+
onDeleteShape = jest.fn(),
8182
onUpdateShapes = jest.fn(),
8283
initialModel = model();
8384
beforeEach(() => {
@@ -91,6 +92,7 @@ describe('HotspotContainer', () => {
9192
outlineColor: initialModel.outlineColor,
9293
onUpdateImageDimension: onUpdateImageDimension,
9394
onUpdateShapes: onUpdateShapes,
95+
onDeleteShape: onDeleteShape,
9496
onImageUpload: onImageUpload,
9597
shapes: initialModel.shapes,
9698
...extras,
@@ -210,6 +212,54 @@ describe('HotspotContainer', () => {
210212
});
211213
});
212214

215+
it('onDeleteShape by id', () => {
216+
console.log('wrapper', wrapper.instance());
217+
wrapper.instance().onDeleteShape('7');
218+
expect(onUpdateShapes).toHaveBeenCalledWith(
219+
groupShapes([
220+
{ correct: true, group: 'rectangles', height: 140, id: '0', index: 0, width: 130, x: 1, y: 1 },
221+
{ group: 'rectangles', height: 140, id: '1', index: 1, width: 130, x: 140, y: 1 },
222+
{ group: 'rectangles', height: 140, id: '2', index: 2, width: 130, x: 280, y: 1 },
223+
{
224+
correct: true,
225+
group: 'polygons',
226+
id: '3',
227+
index: 3,
228+
points: [
229+
{ x: 1, y: 148 },
230+
{ x: 1, y: 288 },
231+
{ x: 129, y: 288 },
232+
{ x: 129, y: 148 },
233+
],
234+
},
235+
{
236+
correct: false,
237+
group: 'polygons',
238+
id: '4',
239+
index: 4,
240+
points: [
241+
{ x: 141, y: 151 },
242+
{ x: 141, y: 289 },
243+
{ x: 269, y: 289 },
244+
{ x: 269, y: 151 },
245+
],
246+
},
247+
{
248+
correct: false,
249+
group: 'polygons',
250+
id: '5',
251+
index: 5,
252+
points: [
253+
{ x: 279, y: 150 },
254+
{ x: 279, y: 289 },
255+
{ x: 407, y: 289 },
256+
{ x: 407, y: 150 },
257+
],
258+
},
259+
]),
260+
);
261+
});
262+
213263
it('onUpdateShapes with no shapes', () => {
214264
wrapper.instance().onUpdateShapes([]);
215265

0 commit comments

Comments
 (0)