Skip to content

🎥 Make videos programmatically with React

add some spring tests

Jonny Burgerff81c5beba32
diff --git a/packages/core/src/test/spring.test.ts b/packages/core/src/test/spring.test.ts
new file mode 100644
index 0000000000..49a1c91ae7
--- /dev/null
+++ b/packages/core/src/test/spring.test.ts
@@ -0,0 +1,38 @@
+import {isApproximatelyTheSame} from '../is-approximately-the-same';
+import {spring} from '../spring';
+
+test('Basic spring should work', () => {
+ expect(
+ spring({
+ fps: 30,
+ frame: 0,
+ })
+ ).toEqual(0);
+
+ expect(
+ spring({
+ fps: 30,
+ frame: 0,
+ from: 1,
+ to: 0,
+ })
+ ).toEqual(1);
+});
+
+test('Spring should go to 1', () => {
+ expect(
+ isApproximatelyTheSame(
+ spring({
+ fps: 30,
+ frame: 1,
+ }),
+ 0.04941510804510185
+ )
+ ).toBe(true);
+ expect(
+ spring({
+ fps: 30,
+ frame: 100,
+ })
+ ).toBe(1);
+});