Files
jamoke/src/lib/server/test/getDiceRoll.test.ts

16 lines
442 B
TypeScript

import { describe, it } from "node:test";
import { getDiceRoll } from "../../getDiceRoll";
import { deepEqual } from "node:assert/strict";
function testRandom() {
const val = [0, 0.2, 0.5, 0.5, 0.7, 0.9];
return () => val.shift()!;
}
describe("getDiceRoll", () => {
it("should return an array of numbers from 1 to 6 with a given length", () => {
let rand = getDiceRoll(6, testRandom());
deepEqual(rand, [0, 1, 3, 3, 4, 6]);
});
});