Skip to content

Instantly share code, notes, and snippets.

@nabrown
Created April 9, 2018 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabrown/cbf6fe5c0dee202adf5c4f988d2b55fd to your computer and use it in GitHub Desktop.
Save nabrown/cbf6fe5c0dee202adf5c4f988d2b55fd to your computer and use it in GitHub Desktop.
A test for a function getRandosFromArray
test('getRandosFromArray returns an array of n random items from an array', () => {
let array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}, {id: 6}, {id: 7}, {id: 8}, {id: 9}]
let n = 2
let items = utils.getRandosFromArray(array, n)
expect(items.length).toBe(n)
expect(array).toContain(items[0])
expect(array).toContain(items[1])
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment