Skip to content

🎥 Make videos programmatically with React

add test for parsePath()

Jonny Burgerbc66707bf777
diff --git a/packages/paths/src/test/parse-path.test.ts b/packages/paths/src/test/parse-path.test.ts
new file mode 100644
index 0000000000..3f22b1f929
--- /dev/null
+++ b/packages/paths/src/test/parse-path.test.ts
@@ -0,0 +1,16 @@
+import {expect, test} from 'vitest';
+import {parsePath} from '../parse-path';
+
+test('Should be able to parse path', () => {
+ expect(parsePath('M 100 100')).toEqual([{type: 'M', x: 100, y: 100}]);
+ expect(parsePath('M 100 100L 200 200')).toEqual([
+ {type: 'M', x: 100, y: 100},
+ {type: 'L', x: 200, y: 200},
+ ]);
+});
+
+test('Should catch invalid paths', () => {
+ expect(() => parsePath('M 100 100L 200 200L')).toThrow(
+ /Malformed path data: L was expected to have numbers afterwards/
+ );
+});