mirror of
https://github.com/liabru/matter-js.git
synced 2025-03-14 00:38:41 -04:00
Axes.rotate unit tests
This commit is contained in:
parent
f2d6ec260a
commit
b363eb3f80
1 changed files with 45 additions and 0 deletions
|
@ -29,5 +29,50 @@ describe('Axes.fromVertices', () => {
|
|||
// TODO: This causes a read from undefined. This should probably be fixed.
|
||||
expect(result).toThrow("Cannot read properties of undefined (reading 'length')");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('Axes.rotate', () => {
|
||||
it('should be able to rotate axes from valid axes', () => {
|
||||
// Arrange
|
||||
const axes = Axes.fromVertices(getTestVerticesSqaureWithoutBody());
|
||||
const angle = 90.;
|
||||
|
||||
// Act
|
||||
Axes.rotate(axes, angle);
|
||||
|
||||
// Assert
|
||||
assertXY(axes[0], -0.8939966636005579, -0.4480736161291702);
|
||||
assertXY(axes[1], 0.4480736161291702, -0.8939966636005579);
|
||||
|
||||
});
|
||||
|
||||
it('should not be able to rotate axes from valid axes and undefined angle', () => {
|
||||
// Arrange
|
||||
const axes = Axes.fromVertices(getTestVerticesSqaureWithoutBody());
|
||||
const angle = undefined;
|
||||
|
||||
// Act
|
||||
Axes.rotate(axes, angle);
|
||||
|
||||
// Assert
|
||||
// TODO: This causes the result to be NaN. This probaby should be fixed.
|
||||
assertXY(axes[0], NaN, NaN );
|
||||
assertXY(axes[1], NaN, NaN );
|
||||
|
||||
});
|
||||
|
||||
it('should not be able to rotate axes from undefined axes', () => {
|
||||
// Arrange
|
||||
const axes = undefined;
|
||||
const angle = 90.;
|
||||
|
||||
// Act
|
||||
const result = () => Axes.rotate(axes, angle);
|
||||
|
||||
// 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