mirror of
https://github.com/liabru/matter-js.git
synced 2025-03-14 00:38:41 -04:00
Vertices.isConvex unit tests
This commit is contained in:
parent
9b7e93b582
commit
412614c40e
1 changed files with 47 additions and 0 deletions
|
@ -904,5 +904,52 @@ describe('Vertices.hull', () => {
|
|||
// TODO: This causes a read from undefined. This should probably be fixed.
|
||||
expect(result).toThrow("Cannot read properties of undefined (reading 'slice')");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('Vertices.isConvex', () => {
|
||||
it('should be able to determine if valid vertices are convex', () => {
|
||||
// Arrange
|
||||
const vertices = getTestVerticesSqaureWithoutBody();
|
||||
|
||||
// Act
|
||||
const result = Vertices.isConvex(vertices);
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(true);
|
||||
|
||||
});
|
||||
|
||||
it('should be able to determine if valid vertices are not convex', () => {
|
||||
// Arrange
|
||||
const vertices = [
|
||||
{ x: 1, y: 1, index: 0, body: undefined },
|
||||
{ x: 5, y: 1, index: 1, body: undefined },
|
||||
{ x: 5, y: 3, index: 2, body: undefined },
|
||||
{ x: 4, y: 4, index: 3, body: undefined },
|
||||
{ x: 3, y: 3, index: 4, body: undefined },
|
||||
{ x: 2, y: 4, index: 5, body: undefined },
|
||||
{ x: 1, y: 3, index: 6, body: undefined },
|
||||
];
|
||||
|
||||
// Act
|
||||
const result = Vertices.isConvex(vertices);
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(false);
|
||||
|
||||
});
|
||||
|
||||
it('should not be able to determine if undefined vertices are convex', () => {
|
||||
// Arrange
|
||||
const vertices = undefined;
|
||||
|
||||
// Act
|
||||
const result = () => Vertices.isConvex(vertices);
|
||||
|
||||
// Assert
|
||||
// TODO: This causes a read from undefined. This should probably be fixed.
|
||||
expect(result).toThrow("Cannot read properties of undefined (reading 'length')");
|
||||
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue