From 27f3136c085036c1efb88976e35f8ff1def71376 Mon Sep 17 00:00:00 2001 From: Marin Atanasov <8436925+tyxla@users.noreply.github.com> Date: Fri, 10 Jun 2022 12:13:08 +0300 Subject: [PATCH] Lodash: Refactor away from _.random() (#41634) --- .../specs/editor/various/taxonomies.test.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/e2e-tests/specs/editor/various/taxonomies.test.js b/packages/e2e-tests/specs/editor/various/taxonomies.test.js index ef651386211e5..551187d654dd9 100644 --- a/packages/e2e-tests/specs/editor/various/taxonomies.test.js +++ b/packages/e2e-tests/specs/editor/various/taxonomies.test.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { random } from 'lodash'; - /** * WordPress dependencies */ @@ -19,6 +14,12 @@ import { const TAG_TOKEN_SELECTOR = '.components-form-token-field__token-text span:not(.components-visually-hidden)'; +function generateRandomNumber() { + // Using `Math.random()` directly is fine in this testing context. + // eslint-disable-next-line no-restricted-syntax + return Math.round( 1 + Math.random() * ( Number.MAX_SAFE_INTEGER - 1 ) ); +} + describe( 'Taxonomies', () => { const canCreatTermInTaxonomy = ( taxonomy ) => { return page.evaluate( ( _taxonomy ) => { @@ -152,7 +153,7 @@ describe( 'Taxonomies', () => { // Click the tag input field. await tagInput.click(); - const tagName = "tag'-" + random( 1, Number.MAX_SAFE_INTEGER ); + const tagName = "tag'-" + generateRandomNumber(); // Type the category name in the field. await tagInput.type( tagName ); @@ -211,7 +212,7 @@ describe( 'Taxonomies', () => { // Click the tag input field. await tagInput.click(); - const tagName = 'tag-' + random( 1, Number.MAX_SAFE_INTEGER ); + const tagName = 'tag-' + generateRandomNumber(); // Type the category name in the field. await tagInput.type( tagName );