Skip to content

Commit

Permalink
Lodash: Refactor away from _.random() (#41634)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Jun 10, 2022
1 parent 14d039e commit 27f3136
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/e2e-tests/specs/editor/various/taxonomies.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { random } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -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 ) => {
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 27f3136

Please sign in to comment.