UNPKG

@zohodesk/components

Version:

In this Package, we Provide Some Basic Components to Build Web App

156 lines 4.31 kB
import React from 'react'; import { render } from '@testing-library/react'; import Switch from "../Switch"; describe('Switch', () => { test('rendering the defult props', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, null)); expect(asFragment()).toMatchSnapshot(); }); test('rendering the checked', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { checked: true, id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the dataId', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { dataId: "data-Switch", id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the disabled and disableTitle', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { disabled: true, disableTitle: "data-disableTitle", id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the text', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { text: "SwitchText", id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the ID', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { id: "SwitchID", text: "SwitchText" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the isReadOnly', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { isReadOnly: true })); expect(asFragment()).toMatchSnapshot(); }); const size = ['small', 'medium']; test.each(size)('rendering the size of- %s', size => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { size: size, id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); const labelSize = ['small', 'medium', 'large']; test.each(labelSize)('rendering the labelSize of- %s', labelSize => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { text: "SwitchText", id: "SwitchID", labelSize: labelSize })); expect(asFragment()).toMatchSnapshot(); }); const labelPalette = ['default', 'primary', 'secondary', 'danger', 'mandatory']; test.each(labelPalette)('rendering the labelSize of- %s', labelPalette => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { text: "SwitchText", id: "SwitchID", labelPalette: labelPalette })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the Name', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { name: "LabelName", id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the Title', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { title: "LabelTitle", id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the Value', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { value: true, id: "SwitchID" })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the CustomClass', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { text: "SwitchText", id: "SwitchID", customClass: { customSwitchWrap: 'SwtichCustomSwitchWrap', customSwitch: 'SwtichCustomSwitch', customSwitchSize: 'SwtichCustomSwitchSize', customLabel: 'SwtichCustomLabel' } })); expect(asFragment()).toMatchSnapshot(); }); test('rendering the CustomProps', () => { const { asFragment } = render( /*#__PURE__*/React.createElement(Switch, { text: "SwitchText", id: "SwitchID", customProps: { SwitchProps: { 'data-switch': true }, LabelProps: { title: 'SwtichTitle' } } })); expect(asFragment()).toMatchSnapshot(); }); });