UNPKG

test-fns

Version:

write usecase driven tests systematically for simpler, safer, and more readable code

20 lines 707 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isTestUuid = exports.genTestUuid = void 0; const uuid_1 = require("uuid"); /** * generates a random uuid namespaced for tests, pattern `beef****-****-****-****-********beef` * * usecase * - produces a uuid that can be clearly identified as one produced for tests */ const genTestUuid = () => { return ['beef', (0, uuid_1.v4)().slice(4, -4), 'beef'].join(''); }; exports.genTestUuid = genTestUuid; /** * decides whether a uuid is namespaced for tests */ const isTestUuid = (userUuid) => /^beef.{4}-.{4}-.{4}-.{4}-.{8}beef$/.test(userUuid); exports.isTestUuid = isTestUuid; //# sourceMappingURL=genTestUuid.js.map