UNPKG

@formio/react

Version:

React renderer for form.io forms.

25 lines (24 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = require("@testing-library/react"); const dom_1 = require("@testing-library/dom"); const usePagination_1 = require("../usePagination"); it('should return correct paginated data when passed a static array', () => { const myData = Array.from({ length: 100, }, (_, i) => i); const { result } = (0, react_1.renderHook)(() => (0, usePagination_1.usePagination)(1, 10, myData)); const { data } = result.current; expect(data).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); }); it('should return correct paginated data when passed a fetch function', async () => { const fakeData = Array.from({ length: 100 }, (_, i) => i); const fetchFunction = async (limit, skip) => { return fakeData.slice(skip, skip + limit); }; const { result } = (0, react_1.renderHook)(() => (0, usePagination_1.usePagination)(1, 10, fetchFunction)); (0, dom_1.waitFor)(() => { const { data } = result.current; expect(data).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); }); });