mirror of
https://github.com/liabru/matter-js.git
synced 2025-03-14 00:38:41 -04:00
Body.nextCategory unit tests
This commit is contained in:
parent
329487609c
commit
e0c9007eb2
1 changed files with 111 additions and 0 deletions
|
@ -236,4 +236,115 @@ describe('Body.nextGroup', () => {
|
|||
expect(Body._nextNonCollidingGroupId).toEqual(-4);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Body.nextCategory', () => {
|
||||
it('should calculate and set the valid next category', () => {
|
||||
jest.isolateModules(() => {
|
||||
// Arrange
|
||||
const Body = require("../../../src/body/Body");
|
||||
|
||||
// Act
|
||||
const result = Body.nextCategory();
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(2);
|
||||
expect(Body._nextCategory).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to calculate and set the valid next category maximum times', () => {
|
||||
jest.isolateModules(() => {
|
||||
// Arrange
|
||||
const Body = require("../../../src/body/Body");
|
||||
|
||||
// Act
|
||||
let result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
|
||||
result = Body.nextCategory();
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(1073741824);
|
||||
expect(Body._nextCategory).toEqual(1073741824);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to calculate and set the valid next category maximum times', () => {
|
||||
jest.isolateModules(() => {
|
||||
// Arrange
|
||||
const Body = require("../../../src/body/Body");
|
||||
|
||||
// Act
|
||||
let result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
result = Body.nextCategory();
|
||||
|
||||
result = Body.nextCategory();
|
||||
|
||||
result = Body.nextCategory();
|
||||
|
||||
// Assert
|
||||
// TODO: This should probably result in an error.
|
||||
expect(result).toEqual(-2147483648);
|
||||
expect(Body._nextCategory).toEqual(-2147483648);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue