Skip to content

Commit

Permalink
feat: add test for randomElement
Browse files Browse the repository at this point in the history
  • Loading branch information
pleb committed Jun 16, 2022
1 parent ff77064 commit 7cff265
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/data-builder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { randomBoolean, randomId, randomNumber, randomNumberBetween, randomString } from '../src'
import { randomBoolean, randomElement, randomId, randomNumber, randomNumberBetween, randomString } from '../src'

describe('Data builder', () => {
describe('randomNumber', () => {
Expand Down Expand Up @@ -32,4 +32,11 @@ describe('Data builder', () => {
expect([true, false].includes(randomBoolean())).toBe(true)
})
})
describe('randomElement', () => {
it('returns a random element', () => {
const elements = [1, 2, 3, 4, 5, 6]
expect(randomElement(elements)).toBeGreaterThanOrEqual(1)
expect(randomElement(elements)).toBeLessThanOrEqual(6)
})
})
})

0 comments on commit 7cff265

Please sign in to comment.