Skip to content

Commit 2eb9144

Browse files
committed
Clean up unit tests
1 parent 3d8dc71 commit 2eb9144

1 file changed

Lines changed: 15 additions & 67 deletions

File tree

packages/grid/src/Grid.test.tsx

Lines changed: 15 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,19 +1255,12 @@ describe('grid-block-events cleanup', () => {
12551255
mouseDown(0, 0, component, {}, separatorX, headerY);
12561256

12571257
// Drag to trigger handleMouseDrag which adds the class
1258-
fireEvent.mouseMove(window, {
1259-
clientX: separatorX + 50,
1260-
clientY: headerY,
1261-
});
1258+
mouseMove(0, 0, component, {}, separatorX + 50, headerY);
12621259

12631260
expect(hasBlockEventsClass()).toBe(true);
12641261

12651262
// Normal mouse up should clean up
1266-
fireEvent.mouseUp(window, {
1267-
clientX: separatorX + 50,
1268-
clientY: headerY,
1269-
button: 0,
1270-
});
1263+
mouseUp(0, 0, component, { button: 0 }, separatorX + 50, headerY);
12711264

12721265
expect(hasBlockEventsClass()).toBe(false);
12731266
});
@@ -1279,27 +1272,16 @@ describe('grid-block-events cleanup', () => {
12791272

12801273
// Start drag
12811274
mouseDown(0, 0, component, {}, separatorX, headerY);
1282-
fireEvent.mouseMove(window, {
1283-
clientX: separatorX + 50,
1284-
clientY: headerY,
1285-
});
1275+
mouseMove(0, 0, component, {}, separatorX + 50, headerY);
12861276

12871277
expect(hasBlockEventsClass()).toBe(true);
12881278

12891279
// Right-click during drag (button=2)
1290-
fireEvent.mouseUp(window, {
1291-
clientX: separatorX + 50,
1292-
clientY: headerY,
1293-
button: 2,
1294-
});
1280+
mouseUp(0, 0, component, { button: 2 }, separatorX + 50, headerY);
12951281

12961282
// Right-click during drag returns early, class should still be present
12971283
// Then complete with left mouse up
1298-
fireEvent.mouseUp(window, {
1299-
clientX: separatorX + 50,
1300-
clientY: headerY,
1301-
button: 0,
1302-
});
1284+
mouseUp(0, 0, component, { button: 0 }, separatorX + 50, headerY);
13031285

13041286
expect(hasBlockEventsClass()).toBe(false);
13051287
});
@@ -1311,30 +1293,19 @@ describe('grid-block-events cleanup', () => {
13111293

13121294
// Start drag
13131295
mouseDown(0, 0, component, {}, separatorX, headerY);
1314-
fireEvent.mouseMove(window, {
1315-
clientX: separatorX + 50,
1316-
clientY: headerY,
1317-
});
1296+
mouseMove(0, 0, component, {}, separatorX + 50, headerY);
13181297

13191298
expect(hasBlockEventsClass()).toBe(true);
13201299

13211300
// Middle mouse button up during drag (button=1) should be ignored
13221301
// Drag should continue
1323-
fireEvent.mouseUp(window, {
1324-
clientX: separatorX + 50,
1325-
clientY: headerY,
1326-
button: 1,
1327-
});
1302+
mouseUp(0, 0, component, { button: 1 }, separatorX + 50, headerY);
13281303

13291304
// Class should still be present since drag is ongoing
13301305
expect(hasBlockEventsClass()).toBe(true);
13311306

13321307
// Left mouse up should properly end the drag and clean up
1333-
fireEvent.mouseUp(window, {
1334-
clientX: separatorX + 50,
1335-
clientY: headerY,
1336-
button: 0,
1337-
});
1308+
mouseUp(0, 0, component, { button: 0 }, separatorX + 50, headerY);
13381309

13391310
expect(hasBlockEventsClass()).toBe(false);
13401311
});
@@ -1375,14 +1346,8 @@ describe('grid-block-events cleanup', () => {
13751346
expect(hasBlockEventsClass()).toBe(false);
13761347

13771348
// Start drag on Grid 1
1378-
fireEvent.mouseDown(component1.canvas!, {
1379-
clientX: separatorX,
1380-
clientY: headerY,
1381-
});
1382-
fireEvent.mouseMove(window, {
1383-
clientX: separatorX + 50,
1384-
clientY: headerY,
1385-
});
1349+
mouseDown(0, 0, component1, {}, separatorX, headerY);
1350+
mouseMove(0, 0, component1, {}, separatorX + 50, headerY);
13861351

13871352
expect(hasBlockEventsClass()).toBe(true);
13881353

@@ -1395,11 +1360,7 @@ describe('grid-block-events cleanup', () => {
13951360
expect(hasBlockEventsClass()).toBe(true);
13961361

13971362
// Complete Grid 1's drag
1398-
fireEvent.mouseUp(window, {
1399-
clientX: separatorX + 50,
1400-
clientY: headerY,
1401-
button: 0,
1402-
});
1363+
mouseUp(0, 0, component1, { button: 0 }, separatorX + 50, headerY);
14031364

14041365
expect(hasBlockEventsClass()).toBe(false);
14051366
});
@@ -1411,10 +1372,7 @@ describe('grid-block-events cleanup', () => {
14111372

14121373
// Start drag
14131374
mouseDown(0, 0, component, {}, separatorX, headerY);
1414-
fireEvent.mouseMove(window, {
1415-
clientX: separatorX + 50,
1416-
clientY: headerY,
1417-
});
1375+
mouseMove(0, 0, component, {}, separatorX + 50, headerY);
14181376

14191377
expect(hasBlockEventsClass()).toBe(true);
14201378

@@ -1433,25 +1391,15 @@ describe('grid-block-events cleanup', () => {
14331391

14341392
// Start drag
14351393
mouseDown(0, 0, component, {}, separatorX, headerY);
1436-
fireEvent.mouseMove(window, {
1437-
clientX: separatorX + 50,
1438-
clientY: headerY,
1439-
});
1394+
mouseMove(0, 0, component, {}, separatorX + 50, headerY);
14401395

14411396
expect(hasBlockEventsClass()).toBe(true);
14421397

14431398
// Move mouse far outside grid (simulating dragging outside window)
1444-
fireEvent.mouseMove(window, {
1445-
clientX: -1000,
1446-
clientY: -1000,
1447-
});
1399+
mouseMove(0, 0, component, {}, -1000, -1000);
14481400

14491401
// Mouse up outside grid boundaries
1450-
fireEvent.mouseUp(window, {
1451-
clientX: -1000,
1452-
clientY: -1000,
1453-
button: 0,
1454-
});
1402+
mouseUp(0, 0, component, { button: 0 }, -1000, -1000);
14551403

14561404
// Should still clean up properly
14571405
expect(hasBlockEventsClass()).toBe(false);

0 commit comments

Comments
 (0)