forked from github/browser-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray-findlastindex.js
29 lines (27 loc) · 913 Bytes
/
array-findlastindex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {apply, arrayFindLastIndex, isPolyfilled, isSupported} from '../lib/array-findlastindex.js'
describe('arrayFindLastIndex', () => {
it('has standard isSupported, isPolyfilled, apply API', () => {
expect(isSupported).to.be.a('function')
expect(isPolyfilled).to.be.a('function')
expect(apply).to.be.a('function')
expect(isSupported()).to.be.a('boolean')
expect(isPolyfilled()).to.equal(false)
})
it('returns value that passes truthy', () => {
expect(arrayFindLastIndex.call([1, 2, 3], v => v === 3)).to.equal(2)
const arr = [1, 2, 3]
const recv = {}
expect(
arrayFindLastIndex.call(
arr,
function (v, i, _arr) {
// eslint-disable-next-line @typescript-eslint/no-invalid-this
expect(this).to.equal(recv)
expect(_arr).to.equal(arr)
expect(v).to.equal(arr[i])
},
recv
)
)
})
})