Skip to content

Commit

Permalink
fix(DropDownItem): when href use a tag (#377)
Browse files Browse the repository at this point in the history
fixes #367
  • Loading branch information
TheSharpieOne authored and eddywashere committed Mar 31, 2017
1 parent fe48e9e commit 96616af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/DropdownItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class DropdownItem extends React.Component {
Tag = 'h6';
} else if (divider) {
Tag = 'div';
} else if (props.href) {
Tag = 'a';
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/__tests__/DropdownItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ describe('DropdownItem', () => {
});
});

describe('link (with href)', () => {
it('should render an anchor tag', () => {
const wrapper = mount(<DropdownItem href="#">GO!</DropdownItem>);

expect(wrapper.find('a').length).toBe(1);
expect(wrapper.find('a').hasClass('dropdown-item')).toBe(true);
expect(wrapper.text()).toBe('GO!');
});
});

describe('onClick', () => {
it('should not be called when disabled', () => {
const e = { preventDefault: jasmine.createSpy('preventDefault') };
Expand Down

0 comments on commit 96616af

Please sign in to comment.