Skip to content

Commit 3c844c3

Browse files
committed
* fix options size to 31px
* creates first test for component rendering
1 parent 89472e2 commit 3c844c3

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/SelectBox/SelectBox.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import propTypes from 'prop-types';
33
import { StyledOptionsList, StyledOptionsListItem } from './SelectBox.styles';
44
import { StyledCutout } from '../Cutout/Cutout';
55

6-
const SelectBox = React.forwardRef(function SelectBox(props) {
6+
const SelectBox = React.forwardRef(function SelectBox(props, ref) {
77
const { options, value, onSelect, width, height } = props;
88
const selectedListItemRef = useRef(null);
99
const listRef = useRef(null);
@@ -59,7 +59,7 @@ const SelectBox = React.forwardRef(function SelectBox(props) {
5959
};
6060

6161
return (
62-
<StyledCutout>
62+
<StyledCutout ref={ref}>
6363
<StyledOptionsList
6464
style={{ width, height }}
6565
ref={listRef}
@@ -93,7 +93,7 @@ SelectBox.defaultProps = {
9393
SelectBox.propTypes = {
9494
onSelect: propTypes.func,
9595
options: propTypes.arrayOf(
96-
propTypes.objectOf({ value: propTypes.number, label: propTypes.string })
96+
propTypes.shape({ value: propTypes.number, label: propTypes.string })
9797
),
9898
value: propTypes.number,
9999
width: propTypes.string,

src/SelectBox/SelectBox.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { renderWithTheme } from '../../test/utils';
3+
import SelectBox from './SelectBox';
4+
5+
const options = [
6+
{ label: 'ten', value: 0 },
7+
{ label: 'twenty', value: 1 },
8+
{ label: 'thirty', value: 2 }
9+
];
10+
11+
describe('<SelectBox />', () => {
12+
beforeEach(() => {
13+
window.HTMLElement.prototype.scrollIntoView = function() {};
14+
});
15+
it('should be able to mount the component', () => {
16+
const { container } = renderWithTheme(<SelectBox options={options} />);
17+
expect(container.querySelector('ul').querySelector('li').textContent).toBe(
18+
'ten'
19+
);
20+
});
21+
});

src/SelectBox/SelectBox.styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const StyledOptionsListItem = styled.li`
1818
box-sizing: border-box;
1919
margin: 0;
2020
padding: 0;
21-
height: ${blockSizes.md};
21+
height: 31px;
2222
line-height: calc(${blockSizes.md} - 4px);
2323
background: ${({ theme, isSelected }) =>
2424
isSelected ? theme.hoverBackground : 'none'};

0 commit comments

Comments
 (0)