Skip to content

🎥 Make videos programmatically with React

add test for get bounding box

Jonny Burgerce15d33ec68d
diff --git a/packages/paths/src/test/get-bounding-box.test.ts b/packages/paths/src/test/get-bounding-box.test.ts
new file mode 100644
index 0000000000..663d2c6583
--- /dev/null
+++ b/packages/paths/src/test/get-bounding-box.test.ts
@@ -0,0 +1,24 @@
+import {expect, test} from 'vitest';
+import {getBoundingBox} from '../get-bounding-box';
+import {resetPath} from '../reset-path';
+
+test('getBoundingBox()', () => {
+ expect(
+ getBoundingBox('M 35,50 a 25,25,0,1,1,50,0 a 25,25,0,1,1,-50,0')
+ ).toEqual({
+ x1: 35,
+ x2: 85,
+ y1: 24.999999999999993,
+ y2: 75,
+ });
+});
+
+test('reset path should have 0 bounding box', () => {
+ const newPath = resetPath('M 35,50 a 25,25,0,1,1,50,0 a 25,25,0,1,1,-50,0');
+ const {x1, x2, y1, y2} = getBoundingBox(newPath);
+
+ expect(x1).approximately(0, 0.000001);
+ expect(x2).approximately(50, 0.00001);
+ expect(y1).approximately(0, 0.000001);
+ expect(y2).approximately(50, 0.00001);
+});