Skip to content

Commit

Permalink
Add tests for AABB
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Jun 29, 2020
1 parent 39894cf commit 0cb5a35
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { isEqual } from './aabb';
import { AABB } from '../types';

describe('AABB', () => {
const minimumX = 0;
const minimumY = 0;
const maximumX = 0;
const maximumY = 0;

let aabb: AABB;

beforeEach(() => {
aabb = { minimum: [minimumX, minimumY], maximum: [maximumX, maximumY] };
});
it('should be equal to an AABB with the same values', () => {
expect(isEqual(aabb, { minimum: [minimumX, minimumY], maximum: [maximumX, maximumY] })).toBe(
true
);
});

it('should not be equal to an AABB with a different minimum X value', () => {
expect(
isEqual(aabb, { minimum: [minimumX + 1, minimumY], maximum: [maximumX, maximumY] })
).toBe(false);
});
it('should not be equal to an AABB with a different minimum Y value', () => {
expect(
isEqual(aabb, { minimum: [minimumX, minimumY + 1], maximum: [maximumX, maximumY] })
).toBe(false);
});
it('should not be equal to an AABB with a different maximum X value', () => {
expect(
isEqual(aabb, { minimum: [minimumX, minimumY], maximum: [maximumX + 1, maximumY] })
).toBe(false);
});
it('should not be equal to an AABB with a different maximum Y value', () => {
expect(
isEqual(aabb, { minimum: [minimumX, minimumY], maximum: [maximumX, maximumY + 1] })
).toBe(false);
});
});

0 comments on commit 0cb5a35

Please sign in to comment.