@zohodesk/dot
Version:
In this Library, we Provide Some Basic Components to Build Your Application
77 lines (75 loc) • 2.03 kB
JavaScript
import React from 'react';
import { render, cleanup, fireEvent } from '@testing-library/react';
import Search from "../Search";
afterEach(cleanup);
describe('Search', () => {
test('rendering the defult props', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Search, null));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the search active', () => {
const {
asFragment,
getByRole
} = render( /*#__PURE__*/React.createElement(Search, null));
fireEvent.focus(getByRole('textbox'));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the prop hasSeparator is true', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Search, {
hasSeparator: true
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the prop hasSeparator is false', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Search, {
hasSeparator: false
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the renderChildren props via function', () => {
const options = [{
value: 'All Fields',
id: '1'
}, {
value: 'Account',
id: '3'
}, {
value: 'Customer Place',
id: '4'
}, {
value: 'Conatct ID',
id: '5'
}];
function renderChildren(_ref) {
let {
value
} = _ref;
return /*#__PURE__*/React.createElement("div", null, value);
}
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Search, {
value: "All Fields",
renderChildren: renderChildren,
options: options
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the customized style search', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Search, {
customStyle: {
wrapper: "searchWrapperClass"
}
}));
expect(asFragment()).toMatchSnapshot();
});
});