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

Vertices.centre unit tests

This commit is contained in:
gsenden 2024-05-17 21:53:26 +02:00
parent 0c151ae7e7
commit bc22f035fa

View file

@ -328,4 +328,31 @@ describe('Vertices.rotate', () => {
expect(result).toThrow("Cannot read properties of undefined (reading 'length')");
});
});
});
describe('Vertices.centre', () => {
it('should be able to get the centre of the valid vertices', () => {
// Arrange
const vertices = testVerticesSqaureWithoutBody;
// Act
const result = Vertices.centre(vertices);
// Assert
assertXY(result, 2., 2.);
});
it('should not be able to get the centre of undefined vertices', () => {
// Arrange
const vertices = undefined;
// Act
const result = () => Vertices.centre(vertices);
// Assert
// TODO: This causes a read from undefined. This should probably be fixed.
expect(result).toThrow("Cannot read properties of undefined (reading 'length')");
});
});