Skip to content

🎥 Make videos programmatically with React

add test for serializeInstructions()

Jonny Burgera63c48aade78
diff --git a/packages/paths/src/test/serialize-instructions.test.ts b/packages/paths/src/test/serialize-instructions.test.ts
new file mode 100644
index 0000000000..f507ecd7d2
--- /dev/null
+++ b/packages/paths/src/test/serialize-instructions.test.ts
@@ -0,0 +1,33 @@
+import {expect, test} from 'vitest';
+import {serializeInstructions} from '../serialize-instructions';
+
+test('Should serialize instructions', () => {
+ expect(
+ serializeInstructions([
+ {
+ type: 'M',
+ x: 100,
+ y: 100,
+ },
+ {
+ type: 'z',
+ },
+ ])
+ ).toBe('M 100 100 z');
+});
+
+test('Should not serialize bad instructions', () => {
+ expect(() =>
+ serializeInstructions([
+ {
+ type: 'M',
+ x: 100,
+ y: 100,
+ },
+ {
+ // @ts-expect-error
+ type: 'X',
+ },
+ ])
+ ).toThrow(/Unknown instruction type: X/);
+});