mirror of
https://github.com/liabru/matter-js.git
synced 2025-03-14 00:38:41 -04:00
Axes.fromVertices unit tests
This commit is contained in:
parent
412614c40e
commit
f2d6ec260a
1 changed files with 33 additions and 0 deletions
33
test/unit/geometry/Axes.spec.js
Normal file
33
test/unit/geometry/Axes.spec.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const {assertXY} = require("../TestUtil");
|
||||
const {
|
||||
getTestVerticesSqaureWithoutBody,
|
||||
} = require("../TestData");
|
||||
const Axes = require("../../../src/geometry/Axes");
|
||||
|
||||
describe('Axes.fromVertices', () => {
|
||||
it('should be able to create axes from valid vertices', () => {
|
||||
// Arrange
|
||||
const vertices = getTestVerticesSqaureWithoutBody();
|
||||
|
||||
// Act
|
||||
const result = Axes.fromVertices(vertices);
|
||||
|
||||
// Assert
|
||||
assertXY(result[0], 0., 1.);
|
||||
assertXY(result[1], -1., 0.);
|
||||
|
||||
});
|
||||
|
||||
it('should not be able to create axes from undefined vertices', () => {
|
||||
// Arrange
|
||||
const vertices = undefined;
|
||||
|
||||
// Act
|
||||
const result = () => Axes.fromVertices(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