only load non assigned tags
fix custom onClick events
This commit is contained in:
@ -18,6 +18,11 @@ class Tag extends React.Component {
|
||||
* click handling for a Tag
|
||||
*/
|
||||
TagClick() {
|
||||
if (this.props.onclick) {
|
||||
this.props.onclick();
|
||||
return;
|
||||
}
|
||||
|
||||
const tag = this.props.children.toString().toLowerCase();
|
||||
|
||||
// call callback functin to switch to category page with specified tag
|
||||
|
@ -31,4 +31,17 @@ describe('<Tag/>', function () {
|
||||
|
||||
expect(func).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('test custom onclick function', function () {
|
||||
const func = jest.fn();
|
||||
|
||||
const wrapper = shallow(<Tag
|
||||
onclick={() => {func()}}>test</Tag>);
|
||||
|
||||
expect(func).toBeCalledTimes(0);
|
||||
|
||||
wrapper.simulate("click");
|
||||
|
||||
expect(func).toBeCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user