verdigris/tests/helpers/math.test.ts
2025-09-17 20:03:45 -06:00

66 lines
955 B
TypeScript

import { expect, test } from 'bun:test'
import { absDegrees } from '../../src/helpers/math'
test('degrees: 0 is valid', () => {
expect(
absDegrees(0)
).toBe(0)
})
test('degrees: if <= 360 return same number', () => {
expect(
absDegrees(1)
).toBe(1)
expect(
absDegrees(180)
).toBe(180)
expect(
absDegrees(359)
).toBe(359)
expect(
absDegrees(360)
).toBe(360)
})
test('degrees: if > 360 return equivilent degree within 360', () => {
expect(
absDegrees(361)
).toBe(1)
expect(
absDegrees(540)
).toBe(180)
expect(
absDegrees(719)
).toBe(359)
expect(
absDegrees(720)
).toBe(360)
})
test('degrees: if < 0 return equivilent degree within 360', () => {
expect(
absDegrees(-361)
).toBe(1)
expect(
absDegrees(-180)
).toBe(180)
expect(
absDegrees(-540)
).toBe(180)
expect(
absDegrees(-719)
).toBe(359)
expect(
absDegrees(-720)
).toBe(360)
})