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

Body.getSpeed unit tests

This commit is contained in:
gsenden 2024-05-31 10:31:30 +02:00
parent 5b06c485a1
commit 2fc7fff2a6

View file

@ -1584,4 +1584,29 @@ describe('Body.getVelocity', () => {
expect(result).toThrow(/^Cannot .* properties of undefined \(.* '.*'\)$/);
});
});
describe('Body.getSpeed', () => {
it('should be able to get the speed from a valid body', () => {
// Arrange
const body = getTestBodyWithPartsWithParent();
// Act
let result = Body.getSpeed(body);
// Assert
assertFloat(result, 0.7542472332656507);
});
it('should not be able to get the speed from an undefined body', () => {
// Arrange
const body = undefined;
// Act
let result = () => Body.getSpeed(body);
// Assert
// TODO: This causes a read or set from undefined. This should probably be fixed.
expect(result).toThrow(/^Cannot .* properties of undefined \(.* '.*'\)$/);
});
});