only load non assigned tags

fix custom onClick events
This commit is contained in:
2020-09-26 18:43:30 +00:00
parent b36327b332
commit 8f88aa3c02
5 changed files with 191 additions and 49 deletions

View File

@ -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

View File

@ -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);
});
});