UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

60 lines (43 loc) 1.21 kB
import { isIndexInRange } from ".."; describe("isIndexInRange", () => { it("first element", () => { const index = 0; const length = 3; expect(isIndexInRange(index, length)).toBe(true); }); it("last element", () => { const index = 2; const length = 3; expect(isIndexInRange(index, length)).toBe(true); }); it("index out of range", () => { const index = 3; const length = 3; expect(isIndexInRange(index, length)).toBe(false); }); it("negative index", () => { const index = -1; const length = 3; expect(isIndexInRange(index, length)).toBe(false); }); it("first element, but empty array", () => { const index = 0; const length = 0; expect(isIndexInRange(index, length)).toBe(false); }); it("index is NaN", () => { const index = NaN; const length = 3; expect(isIndexInRange(index, length)).toBe(false); }); it("index is Infinity", () => { const index = Infinity; const length = 3; expect(isIndexInRange(index, length)).toBe(false); }); it("index is -Infinity", () => { const index = -Infinity; const length = 3; expect(isIndexInRange(index, length)).toBe(false); }); });