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

Vertices.clockwiseSort unit tests

This commit is contained in:
gsenden 2024-05-20 11:05:15 +02:00
parent 59956d99d5
commit 7aec8ec58d

View file

@ -838,5 +838,41 @@ describe('Vertices.chamfer', () => {
// TODO: This causes a read from undefined. This should probably be fixed.
expect(result).toThrow("Cannot read properties of undefined (reading 'length')");
});
});
describe('Vertices.clockwiseSort', () => {
it('should be able to sort valid vertices', () => {
// Arrange
const temp = getTestVerticesSqaureWithoutBody();
const vertices = [];
vertices.push(temp[2]);
vertices.push(temp[3]);
vertices.push(temp[0]);
vertices.push(temp[1]);
// Act
const result = Vertices.clockwiseSort(vertices);
// Assert
assertXY(result[0], 1., 1.);
assertXY(result[1], 3., 1.);
assertXY(result[2], 3., 3.);
assertXY(result[3], 1., 3.);
});
it('should not be able to sort undefined vertices', () => {
// Arrange
const vertices = undefined;
// Act
const result = () => Vertices.clockwiseSort(vertices);
// Assert
// TODO: This causes a read from undefined. This should probably be fixed.
expect(result).toThrow("Cannot read properties of undefined (reading 'length')");
});
});