Much more thorough tests! (#1053)

This commit is contained in:
Pete Hunt 2020-03-23 16:38:41 -07:00 committed by GitHub
parent d4ff5cb926
commit bd7856adf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 11883 additions and 24 deletions

18
src/random.ts Normal file
View file

@ -0,0 +1,18 @@
import { Random } from "roughjs/bin/math";
import nanoid from "nanoid";
let random = new Random(Date.now());
let testIdBase = 0;
export function randomInteger() {
return Math.floor(random.next() * 2 ** 31);
}
export function reseed(seed: number) {
random = new Random(seed);
testIdBase = 0;
}
export function randomId() {
return process.env.NODE_ENV === "test" ? `id${testIdBase++}` : nanoid();
}