Skip to content

Commit

Permalink
fix(tests): fix flaky number test (#11443)
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy committed Feb 9, 2022
1 parent 25923c0 commit 9c12f7b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/bp/src/common/number.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { closest } from './number'

const randomNumber = (max = 100) => Math.floor(Math.random() * max)
const randomNumber = (max = 100) => {
const number = Math.floor(Math.random() * max)

// When we get 0, the test fails
return number > 0 ? number : randomNumber(max)
}

const arrayGenerator = (size = 10): number[] => {
return Array.from({ length: size }, () => randomNumber())
}
Expand Down

0 comments on commit 9c12f7b

Please sign in to comment.