31 lines
705 B
JavaScript
31 lines
705 B
JavaScript
import { describe, it, expect } from "vitest";
|
|
|
|
import {
|
|
dec2hex,
|
|
getRandomIntInclusive,
|
|
roundPrecision
|
|
} from '../src/utils/MathHelpers.mjs';
|
|
|
|
describe("dec2hex", () => {
|
|
it('should convert decimal to hexadecimal values', () => {
|
|
expect(dec2hex(255)).toBe('0xff');
|
|
});
|
|
});
|
|
|
|
describe("getRandomIntInclusive", () => {
|
|
it('should create a random number from min to max inclusive', () => {
|
|
let val = getRandomIntInclusive(1, 5);
|
|
expect(val).toBeGreaterThanOrEqual(1);
|
|
expect(val).toBeLessThanOrEqual(5);
|
|
});
|
|
});
|
|
|
|
describe("roundPrecision", () => {
|
|
it('should round numbers to a given precision', () => {
|
|
let val = roundPrecision(10.1234, 2);
|
|
expect(val).toBe(10.12);
|
|
});
|
|
});
|
|
|
|
// __END__
|