Files
JavaScript.utils/tests/MathHelpers.test.js
Clemens Schwaighofer ea9882256e Adding vitest for testing
Currently implemented

- FormatBytes
- MathHelpers
2025-03-07 17:24:52 +09:00

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__