Skip to content

Commit

Permalink
feat(dropdown-list, storybook): add icon to dropdown-list
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamsTardif committed May 27, 2024
1 parent 47a5970 commit fe828ee
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 1 deletion.
29 changes: 29 additions & 0 deletions packages/react/src/components/dropdown-list/dropdown-list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ describe('Dropdown list', () => {
});
});

describe('icon is handled', () => {
test('the icon is set according to the iconName prop', () => {
const wrapper = shallow(<DropdownList options={provinces} iconName="menu" />);

expect(getByTestId(wrapper, 'textbox-icon').prop('name')).toBe('menu');
});

test('the icon is not set when the iconName prop is undefined', () => {
const wrapper = shallow(<DropdownList options={provinces} />);

const iconComponent = getByTestId(wrapper, 'textbox-icon');
expect(iconComponent.exists()).toBe(false);
});
});

describe('onChange callback', () => {
test('callback is fired when an option is selected', () => {
const callback = jest.fn();
Expand Down Expand Up @@ -478,4 +493,18 @@ describe('Dropdown list', () => {

expect(tree).toMatchSnapshot();
});

test('matches the snapshot (icon)', () => {
const tree = renderWithProviders(
<DropdownList
defaultOpen
label="Select an option"
hint="Hint"
options={provinces}
iconName="menu"
/>,
);

expect(tree).toMatchSnapshot();
});
});
Loading

0 comments on commit fe828ee

Please sign in to comment.