mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-23 18:29:09 +00:00
Co-authored-by: Mikael Finstad <finstaden@gmail.com> Co-authored-by: Nick Rutten <2504906+nickrttn@users.noreply.github.com> Co-authored-by: Murderlon <merlijn@soverin.net> Co-authored-by: Artur Paikin <artur@arturpaikin.com>
16 lines
622 B
JavaScript
16 lines
622 B
JavaScript
import { describe, expect, it } from 'vitest'
|
|
import findIndex from './findIndex.js'
|
|
|
|
describe('findIndex', () => {
|
|
it('should return index of an object in an array, that matches a predicate', () => {
|
|
const arr = [{ name: 'foo' }, { name: 'bar' }, { name: '123' }]
|
|
const index = findIndex(arr, (item) => item.name === 'bar')
|
|
expect(index).toEqual(1)
|
|
})
|
|
|
|
it('should return -1 when no object in an array matches a predicate', () => {
|
|
const arr = [{ name: 'foo' }, { name: 'bar' }, { name: '123' }]
|
|
const index = findIndex(arr, (item) => item.name === 'hello')
|
|
expect(index).toEqual(-1)
|
|
})
|
|
})
|