Adding vitest for testing
Currently implemented - FormatBytes - MathHelpers
This commit is contained in:
30
tests/MathHelpers.test.js
Normal file
30
tests/MathHelpers.test.js
Normal file
@@ -0,0 +1,30 @@
|
||||
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__
|
||||
Reference in New Issue
Block a user