UNPKG

@findify/react-components

Version:
46 lines (44 loc) 1.53 kB
import { shallow } from 'enzyme'; import MapArray from "./index"; import itemMock from "../../../../jest/item.mock"; import { jsxs as _jsxs } from "react/jsx-runtime"; import { jsx as _jsx } from "react/jsx-runtime"; var items = [itemMock('Test Title', 'https://picsum.photos/100/200'), itemMock('Test Title 2', 'https://picsum.photos/100/200')]; describe('MapArray', function () { it('renders correctly', function () { expect(shallow( /*#__PURE__*/_jsx(MapArray, { array: items, factory: function factory(_ref) { var item = _ref.item, key = _ref.key; return /*#__PURE__*/_jsxs("div", { children: [item.get('title'), " ", item.get('image_url')] }, key); }, keyAccessor: function keyAccessor(item) { return item.hashCode(); } }))).toMatchSnapshot(); }); it('respects limit property', function () { var testArray = []; for (var i = 0; i < 100; i += 1) { testArray.push(itemMock('Test title 2', 'some image url')); } expect(shallow( /*#__PURE__*/_jsx(MapArray, { array: testArray, factory: function factory(_ref2) { var item = _ref2.item, key = _ref2.key, index = _ref2.index; return /*#__PURE__*/_jsxs("div", { children: [item.get('title'), " ", item.get('image_url')] }, key + '_' + index); }, limit: 4, keyAccessor: function keyAccessor(item) { return item.hashCode(); } }))).toMatchSnapshot(); }); });