Skip to content

Commit

Permalink
feat: addressed review points
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Mukiienko committed May 4, 2022
1 parent c9603b2 commit f73c11c
Show file tree
Hide file tree
Showing 14 changed files with 920 additions and 784 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ exports[`AutosuggestDeprecated rendering should initially render empty component
className="AutosuggestDeprecated__field"
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -180,7 +180,7 @@ exports[`AutosuggestDeprecated rendering should render all suggestions from the
className="AutosuggestDeprecated__field"
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -491,7 +491,7 @@ exports[`AutosuggestDeprecated rendering should render icon correctly if passed
className="AutosuggestDeprecated__field"
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -664,7 +664,7 @@ exports[`AutosuggestDeprecated rendering should render noSuggestions placeholder
className="AutosuggestDeprecated__field"
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -833,7 +833,7 @@ exports[`AutosuggestDeprecated rendering should render suggestions also if it pa
className="AutosuggestDeprecated__field"
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down
8 changes: 4 additions & 4 deletions src/components/FieldWrapper/FieldWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Props extends React.HTMLAttributes<HTMLDivElement> {
/** show dropdown icon */
showArrow?: boolean;
/** set direction of dropdown icon (default drop down) */
isArrowDropUp?: boolean;
isArrowUp?: boolean;
/** show Clear button on hover even if there are no selectedSuggestions passed */
showClearButton?: boolean;
/** clear button label */
Expand All @@ -38,7 +38,7 @@ export const FieldWrapper: React.FC<Props> = React.forwardRef((props, ref) => {
const {
children,
showArrow,
isArrowDropUp,
isArrowUp,
clearLabel,
showClearButton,
onClear,
Expand All @@ -62,7 +62,7 @@ export const FieldWrapper: React.FC<Props> = React.forwardRef((props, ref) => {
)}

{showArrow &&
(isArrowDropUp ? (
(isArrowUp ? (
<IoMdArrowDropup {...elem('dropdownIcon')} />
) : (
<IoMdArrowDropdown {...elem('dropdownIcon')} />
Expand All @@ -75,7 +75,7 @@ FieldWrapper.displayName = 'FieldWrapper';

FieldWrapper.defaultProps = {
showArrow: false,
isArrowDropUp: false,
isArrowUp: false,
showClearButton: false,
clearLabel: '',
onClear: null,
Expand Down
16 changes: 15 additions & 1 deletion src/components/FieldWrapper/__tests__/FieldWrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FieldWrapper } from '../FieldWrapper';

describe('FieldWrapper', () => {
it('should render correctly', () => {
const wrapper = mount(<FieldWrapper showArrow>some children</FieldWrapper>);
const wrapper = mount(<FieldWrapper>some children</FieldWrapper>);

expect(toJson(wrapper)).toMatchSnapshot();
expect(wrapper.find('button')).toHaveLength(0);
Expand All @@ -19,6 +19,20 @@ describe('FieldWrapper', () => {
expect(toJson(wrapper)).toMatchSnapshot();
expect(wrapper.find('button')).toHaveLength(1);
});
it('should render arrow icon pointing down', () => {
const wrapper = mount(<FieldWrapper showArrow>some children</FieldWrapper>);

expect(toJson(wrapper)).toMatchSnapshot();
});
it('should render arrow icon pointing up', () => {
const wrapper = mount(
<FieldWrapper showArrow isArrowUp>
some children
</FieldWrapper>
);

expect(toJson(wrapper)).toMatchSnapshot();
});
it('should call onClear callback correctly', () => {
const onClearMock = jest.fn();
const wrapper = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`FieldWrapper should add clear button if showClearButton is true 1`] = `
<FieldWrapper
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={null}
showArrow={false}
Expand Down Expand Up @@ -42,11 +42,11 @@ exports[`FieldWrapper should add clear button if showClearButton is true 1`] = `
</FieldWrapper>
`;

exports[`FieldWrapper should render correctly 1`] = `
exports[`FieldWrapper should render arrow icon pointing down 1`] = `
<FieldWrapper
clearLabel=""
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={null}
showArrow={true}
Expand Down Expand Up @@ -97,3 +97,82 @@ exports[`FieldWrapper should render correctly 1`] = `
</div>
</FieldWrapper>
`;

exports[`FieldWrapper should render arrow icon pointing up 1`] = `
<FieldWrapper
clearLabel=""
disabled={false}
isArrowUp={true}
isFocused={false}
onClear={null}
showArrow={true}
showClearButton={false}
>
<div
className="FieldWrapper"
disabled={false}
>
<div
className="FieldWrapper__content"
>
some children
</div>
<IoMdArrowDropup
className="FieldWrapper__dropdownIcon"
>
<IconBase
attr={
Object {
"viewBox": "0 0 512 512",
}
}
className="FieldWrapper__dropdownIcon"
>
<svg
className="FieldWrapper__dropdownIcon"
fill="currentColor"
height="1em"
stroke="currentColor"
strokeWidth="0"
style={
Object {
"color": undefined,
}
}
viewBox="0 0 512 512"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M128 320l128-128 128 128z"
key="0"
/>
</svg>
</IconBase>
</IoMdArrowDropup>
</div>
</FieldWrapper>
`;

exports[`FieldWrapper should render correctly 1`] = `
<FieldWrapper
clearLabel=""
disabled={false}
isArrowUp={false}
isFocused={false}
onClear={null}
showArrow={false}
showClearButton={false}
>
<div
className="FieldWrapper"
disabled={false}
>
<div
className="FieldWrapper__content"
>
some children
</div>
</div>
</FieldWrapper>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ exports[`<LocationAutocomplete/> that renders a location search field should pas
className="AutosuggestDeprecated__field"
clearLabel=""
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -688,7 +688,7 @@ exports[`<LocationAutocomplete/> that renders a location search field should ren
className="AutosuggestDeprecated__field"
clearLabel=""
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={[Function]}
onClick={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ exports[`LocationSelectorDialog component should render correctly 1`] = `
className="AutosuggestDeprecated__field"
clearLabel=""
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`LocationSelector component should render LocationSelector properly when
className="LocationSelector__mainTextButtonWrapper"
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={true}
onClear={[MockFunction]}
onClick={[Function]}
Expand Down Expand Up @@ -478,7 +478,7 @@ exports[`LocationSelector component should render LocationSelector propertly whe
className="LocationSelector__mainTextButtonWrapper"
clearLabel="Clear"
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={[MockFunction]}
onClick={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ exports[`Autosuggest rendering should initially render empty component correctly
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -224,7 +224,7 @@ exports[`Autosuggest rendering should initially render focused component correct
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -421,7 +421,7 @@ exports[`Autosuggest rendering should initially render focused component with su
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -1069,7 +1069,7 @@ exports[`Autosuggest rendering should render component with suggestions 1`] = `
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -1703,7 +1703,7 @@ exports[`Autosuggest rendering should render isLoading state 1`] = `
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -2103,7 +2103,7 @@ exports[`Autosuggest rendering should show "no suggestions" placeholder only if
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -2261,7 +2261,7 @@ exports[`Autosuggest rendering should show "no suggestions" placeholder only if
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -2471,7 +2471,7 @@ exports[`Autosuggest rendering should show "no suggestions" placeholder only if
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ exports[`ComboboxMulti rendering should initially render empty component correct
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={false}
isArrowUp={false}
isFocused={false}
onClear={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -409,7 +409,7 @@ exports[`ComboboxMulti rendering should render all suggestions from the list 1`]
className="SelectBase__field"
clearLabel=""
disabled={false}
isArrowDropUp={true}
isArrowUp={true}
isFocused={true}
onClear={[Function]}
onClick={[Function]}
Expand Down
Loading

0 comments on commit f73c11c

Please sign in to comment.