UNPKG

@shopgate/engage

Version:
44 lines 1.67 kB
import React from 'react'; import { mount } from 'enzyme'; import BaseListItem from '@shopgate/pwa-common/components/List/components/Item'; import SheetList from "./index"; import styles from "./style"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; describe('<SheetList />', () => { it('should render with two children', () => { const wrapper = mount(/*#__PURE__*/_jsxs(SheetList, { children: [/*#__PURE__*/_jsx(SheetList.Item, { title: "List Item" }), /*#__PURE__*/_jsx(SheetList.Item, { title: "List Item" })] })); expect(wrapper).toMatchSnapshot(); expect(wrapper.find(SheetList.Item).length).toEqual(2); }); it('should render a child and add styles for list items with images', () => { const wrapper = mount(/*#__PURE__*/_jsx(SheetList, { hasImages: true, children: /*#__PURE__*/_jsx(SheetList.Item, { title: "List Item" }) })); expect(wrapper).toMatchSnapshot(); expect(wrapper.find(SheetList.Item).length).toEqual(1); expect(wrapper.find(BaseListItem).first().hasClass(styles.itemWithImage)).toBeTruthy(); }); it('should not render without children', () => { const wrapper = mount(/*#__PURE__*/_jsx(SheetList, {})); expect(wrapper).toMatchSnapshot(); expect(wrapper.find(SheetList).html()).toBe(null); }); it('should not render invalid children', () => { const wrapper = mount(/*#__PURE__*/_jsxs(SheetList, { children: [/*#__PURE__*/_jsx(SheetList.Item, { title: "List Item" }), "xxx"] })); expect(wrapper).toMatchSnapshot(); expect(wrapper.find(SheetList.Item).length).toEqual(1); }); });