0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-03-14 00:38:41 -04:00

Body.updateVelocities unit tests

This commit is contained in:
gsenden 2024-06-01 09:02:00 +02:00
parent 29b7d55a57
commit de9a506a24

View file

@ -2616,4 +2616,31 @@ describe('Body.update', () => {
// TODO: This causes a read or set from undefined. This should probably be fixed.
expect(result).toThrow(/^Cannot .* properties of undefined \(.* '.*'\)$/);
});
});
describe('Body.updateVelocities', () => {
it('should be able update all velocities and speeds', () => {
// Arrange
const body = getTestBodyWithPartsWithParent();
// Act
Body.updateVelocities(body);
// Assert
assertFloat(body.speed, 0.7542472332656507);
assertFloat(body.angularVelocity, -0.13333333333333333);
assertFloat(body.angularSpeed, 0.13333333333333333);
});
it('should not be able update all velocities and speeds on undefined body', () => {
// Arrange
const body = undefined;
// Act
let result = () => Body.updateVelocities(body);
// Assert
// TODO: This causes a read or set from undefined. This should probably be fixed.
expect(result).toThrow(/^Cannot .* properties of undefined \(.* '.*'\)$/);
});
});