Add event listeners to vue component, fix #400
This commit is contained in:
@@ -52,6 +52,7 @@ export default (iconName, iconNode) => ({
|
|||||||
'stroke-width': strokeWidth,
|
'stroke-width': strokeWidth,
|
||||||
...data.attrs,
|
...data.attrs,
|
||||||
},
|
},
|
||||||
|
on: data?.on || {}
|
||||||
},
|
},
|
||||||
iconNode.map(([tag, attrs]) => createElement(tag, { attrs })),
|
iconNode.map(([tag, attrs]) => createElement(tag, { attrs })),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -41,4 +41,16 @@ describe('Using lucide icon components', () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
expect(wrapper.attributes('style')).toContain('position: absolute')
|
expect(wrapper.attributes('style')).toContain('position: absolute')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call the onClick event', () => {
|
||||||
|
const onClick = jest.fn()
|
||||||
|
const wrapper = mount(Smile, {
|
||||||
|
listeners: {
|
||||||
|
click: onClick
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
wrapper.trigger('click')
|
||||||
|
expect(onClick).toHaveBeenCalled()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user