@@ -298,30 +298,19 @@ describe('uuid4 generation', () => {
298298 }
299299 } ) ;
300300
301- it ( 'returns valid uuid v4 ids via crypto.getRandomValues' , ( ) => {
302- // eslint-disable-next-line @typescript-eslint/no-var-requires
303- const cryptoMod = require ( 'crypto' ) ;
304-
305- const crypto = { getRandomValues : cryptoMod . getRandomValues } ;
306-
307- for ( let index = 0 ; index < 1_000 ; index ++ ) {
308- expect ( uuid4 ( crypto ) ) . toMatch ( uuid4Regex ) ;
309- }
310- } ) ;
311-
312301 it ( 'returns valid uuid v4 ids via crypto.randomUUID' , ( ) => {
313302 // eslint-disable-next-line @typescript-eslint/no-var-requires
314303 const cryptoMod = require ( 'crypto' ) ;
315304
316- const crypto = { getRandomValues : cryptoMod . getRandomValues , randomUUID : cryptoMod . randomUUID } ;
305+ const crypto = { randomUUID : cryptoMod . randomUUID } ;
317306
318307 for ( let index = 0 ; index < 1_000 ; index ++ ) {
319308 expect ( uuid4 ( crypto ) ) . toMatch ( uuid4Regex ) ;
320309 }
321310 } ) ;
322311
323312 it ( "return valid uuid v4 even if crypto doesn't exists" , ( ) => {
324- const crypto = { getRandomValues : undefined , randomUUID : undefined } ;
313+ const crypto = { randomUUID : undefined } ;
325314
326315 for ( let index = 0 ; index < 1_000 ; index ++ ) {
327316 expect ( uuid4 ( crypto ) ) . toMatch ( uuid4Regex ) ;
@@ -330,9 +319,6 @@ describe('uuid4 generation', () => {
330319
331320 it ( 'return valid uuid v4 even if crypto invoked causes an error' , ( ) => {
332321 const crypto = {
333- getRandomValues : ( ) => {
334- throw new Error ( 'yo' ) ;
335- } ,
336322 randomUUID : ( ) => {
337323 throw new Error ( 'yo' ) ;
338324 } ,
@@ -342,25 +328,4 @@ describe('uuid4 generation', () => {
342328 expect ( uuid4 ( crypto ) ) . toMatch ( uuid4Regex ) ;
343329 }
344330 } ) ;
345-
346- // Corner case related to crypto.getRandomValues being only
347- // semi-implemented (e.g. Chromium 23.0.1235.0 (151422))
348- it ( 'returns valid uuid v4 even if crypto.getRandomValues does not return a typed array' , ( ) => {
349- // eslint-disable-next-line @typescript-eslint/no-var-requires
350- const cryptoMod = require ( 'crypto' ) ;
351-
352- const getRandomValues = ( typedArray : Uint8Array ) => {
353- if ( cryptoMod . getRandomValues ) {
354- cryptoMod . getRandomValues ( typedArray ) ;
355- }
356- } ;
357-
358- const crypto = { getRandomValues } ;
359-
360- for ( let index = 0 ; index < 1_000 ; index ++ ) {
361- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
362- // @ts -ignore - we are testing a corner case
363- expect ( uuid4 ( crypto ) ) . toMatch ( uuid4Regex ) ;
364- }
365- } ) ;
366331} ) ;
0 commit comments