diff --git a/packages/react-strict-animated/src/web/__tests__/SpringAnimation-test.js b/packages/react-strict-animated/src/web/__tests__/SpringAnimation-test.js new file mode 100644 index 00000000..f33ec6e8 --- /dev/null +++ b/packages/react-strict-animated/src/web/__tests__/SpringAnimation-test.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + */ + +import SpringAnimation from '../animations/SpringAnimation'; + +describe('SpringAnimation (web)', () => { + test('rejects a non-positive stiffness value', () => { + expect( + () => new SpringAnimation({ toValue: 1, stiffness: 0, damping: 10, mass: 1 }) + ).toThrow('Stiffness value must be greater than 0'); + }); + + test('rejects a non-positive damping value', () => { + expect( + () => new SpringAnimation({ toValue: 1, stiffness: 100, damping: 0, mass: 1 }) + ).toThrow('Damping value must be greater than 0'); + }); + + test('rejects a non-positive mass value', () => { + expect( + () => new SpringAnimation({ toValue: 1, stiffness: 100, damping: 10, mass: 0 }) + ).toThrow('Mass value must be greater than 0'); + }); +}); diff --git a/packages/react-strict-animated/src/web/animations/SpringAnimation.js b/packages/react-strict-animated/src/web/animations/SpringAnimation.js index 37ecf8b7..0eb39d1c 100644 --- a/packages/react-strict-animated/src/web/animations/SpringAnimation.js +++ b/packages/react-strict-animated/src/web/animations/SpringAnimation.js @@ -109,7 +109,7 @@ export default class SpringAnimation implements AnimatedAnimation { throw new Error('Damping value must be greater than 0'); } if (this.#mass <= 0) { - throw new Error('Damping value must be greater than 0'); + throw new Error('Mass value must be greater than 0'); } }