forked from remeda/remeda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindLastIndex.test.ts
42 lines (35 loc) · 900 Bytes
/
findLastIndex.test.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
import { findLastIndex } from './findLastIndex';
import { pipe } from './pipe';
const array = [1, 2, 3, 4];
describe('data first', () => {
test('findLastIndex', () => {
expect(findLastIndex(array, x => x % 2 === 1)).toBe(2);
});
test('findLastIndex.indexed', () => {
expect(findLastIndex.indexed(array, x => x % 2 === 1)).toBe(2);
});
test('findLast first value', () => {
expect(findLastIndex(array, x => x === 1)).toEqual(0);
});
test('findLastIndex -1', () => {
expect(findLastIndex(array, x => x === 5)).toBe(-1);
});
});
describe('data last', () => {
test('findLastIndex', () => {
expect(
pipe(
array,
findLastIndex(x => x % 2 === 1)
)
).toEqual(2);
});
test('findLastIndex.indexed', () => {
expect(
pipe(
array,
findLastIndex.indexed(x => x % 2 === 1)
)
).toEqual(2);
});
});