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

Body._totalProperties unit tests

This commit is contained in:
gsenden 2024-06-01 09:52:11 +02:00
parent 1804705c2b
commit abbe4e941b

View file

@ -2704,4 +2704,32 @@ describe('Body.applyForce', () => {
// TODO: This causes a read or set from undefined. This should probably be fixed.
expect(result).toThrow(/^Cannot .* properties of undefined \(.* '.*'\)$/);
});
});
describe('Body._totalProperties', () => {
it('should sum the properties of all compound parts of the given body', () => {
// Arrange
const body = getTestBodyWithPartsWithParent();
// Act
const result = Body._totalProperties(body);
// Assert
assertFloat(result.area, 510.);
assertXY(result.centre, 297.7412587412587, 298.7412587412587);
assertFloat(result.inertia, 566.);
assertFloat(result.mass, 572.);
});
it('should not be able sum the properties of all compound parts of an undefined body', () => {
// Arrange
const body = undefined;
// Act
const result = () => Body._totalProperties(body);
// Assert
// TODO: This causes a read or set from undefined. This should probably be fixed.
expect(result).toThrow(/^Cannot .* properties of undefined \(.* '.*'\)$/);
});
});