ts-prime
Version:
A utility library for JavaScript and Typescript.
11 lines (10 loc) • 419 B
JavaScript
import { uuidv4 } from './uuid';
var mockMath = Object.create(global.Math);
test('uuid mock test', function () {
mockMath.random = function () { return 0.5; };
global.Math = mockMath;
expect(uuidv4()).toEqual('88888888-8888-4888-8888-888888888888');
mockMath.random = function () { return 0.78798; };
global.Math = mockMath;
expect(uuidv4()).toEqual('cccccccc-cccc-4ccc-8ccc-cccccccccccc');
});