{"version":3,"sources":["jsdelivr-header.js","/npm/jest-mock-random@1.1.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACJA,MAAM,YAAc,IAAM,QAAQ,KAAK,8GACjC,UAAY,GAAqB,IAAX,IAAkB,OAAO,MAAM,IAAW,EAAS,GAAM,EAC/E,mBAAsB,IACrB,EAAO,IAAI,YAAY,MAAM,YAHV,QAAQ,KAAK,6GAKrC,EAII,SAAW,OAAO,OAAO,OAAO,MAChC,gBAAkB,KACtB,OAAO,KAAO,QAAQ,EAIlB,WAAc,IAClB,IAAI,EAAgB,EACf,MAAM,QAAQ,KACjB,EAAgB,CAAC,IAGnB,IAAI,EAAQ,EAEZ,MAAO,KACL,GAA6B,IAAzB,EAAc,OAChB,MAAM,IAAI,UAAU,0CAMtB,OAJmB,EAxBT,IAAI,YAAY,MAAM,YAHV,QAAQ,KAAK,8GA4B/B,GAAS,EAAc,SACzB,EAAQ,GAEH,EAAc,IAAQ,CAC9B,EAGG,WAAc,IAClB,MAAM,EAAW,OAAO,OAAO,OAAO,MACtC,EAAS,OAAS,WAAW,GAC7B,OAAO,KAAO,CAAQ,EAIlB,kBAAqB,IAEzB,YAAW,KACT,WAAW,EAAY,IAGzB,WAAU,KACR,iBAAiB,GACjB,EAIJ,OAAO,QAAU,CACf,oCACA,sBACA","file":"/npm/jest-mock-random@1.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/jest-mock-random@1.1.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// Warning in case the passed value is not a decimal\n// eslint-disable-next-line no-console\nconst showWarning = () => console.warn('WARNING: The value that you are using to mock random is not a decimal and it is breaking the real contract');\nconst isDecimal = number => number === 0 || (!Number.isNaN(number) && number % 1 !== 0);\nconst warnBrokenContract = (values) => {\n  if (!values.map(parseFloat).every(isDecimal)) {\n    showWarning();\n  }\n};\n\n// Copy the global Math object in order to reset it\nconst mathCopy = Object.create(global.Math);\nconst resetMockRandom = () => {\n  global.Math = mathCopy;\n};\n\n// randomMock implementation\nconst randomMock = (returnValues) => {\n  let arrayOfValues = returnValues;\n  if (!Array.isArray(returnValues)) {\n    arrayOfValues = [returnValues];\n  }\n\n  let index = 0;\n\n  return () => {\n    if (arrayOfValues.length === 0) {\n      throw new TypeError('The value list must contain some value');\n    }\n    warnBrokenContract(arrayOfValues);\n    if (index >= arrayOfValues.length) {\n      index = 0;\n    }\n    return arrayOfValues[index++];\n  };\n};\n// Through a copy of the global Math object we mock the random method\nconst mockRandom = (values) => {\n  const mockMath = Object.create(global.Math);\n  mockMath.random = randomMock(values);\n  global.Math = mockMath;\n};\n\n// When mockRandomWith is called it create the mock beforeEach and reset it after\nconst mockRandomForEach = (valuesArray) => {\n  // eslint-disable-next-line no-undef\n  beforeEach(() => {\n    mockRandom(valuesArray);\n  });\n  // eslint-disable-next-line no-undef\n  afterEach(() => {\n    resetMockRandom();\n  });\n};\n\n\nmodule.exports = {\n  mockRandomForEach,\n  mockRandom,\n  resetMockRandom,\n};\n"]}