UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

37 lines (26 loc) 906 B
import { find } from "../find"; test("example 1", () => { const predicate = <T>(_: T, index: number): boolean => index === 0; const xs = ["1", "2", "2", "3", "4"]; expect(find(predicate, xs)).toBe("1"); }); test("example 2", () => { const predicate = <T>(_: T, index: number): boolean => index === 0; const xs: string[] = []; expect(find(predicate, xs)).toBe(undefined); }); test("example 3", () => { const predicate = () => false; const xs = ["1", "2", "2", "3"]; expect(find(predicate, xs)).toBe(undefined); }); test("example 4", () => { const predicate = <T>(_: T, index: number): boolean => index === 1; const xs = ["1", "2", "2", "3"]; expect(find(predicate, xs)).toBe("2"); }); test("example 5", () => { const predicate = <T>(_: T, index: number): boolean => index === 2; const xs = ["1", "2.1", "2", "3", "2", "4"]; expect(find(predicate, xs)).toBe("2"); });