From 40d28357649142c1d0abc6aed4596fdc7bca97e1 Mon Sep 17 00:00:00 2001 From: Ilias Ismanalijev Date: Mon, 9 Sep 2019 22:53:23 +0200 Subject: [PATCH 1/2] chore: add failing test Adds a failing test to demonstrate that the click handler was broken --- __tests__/icon.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/__tests__/icon.js b/__tests__/icon.js index 0ee712f7..94d0c856 100644 --- a/__tests__/icon.js +++ b/__tests__/icon.js @@ -49,4 +49,23 @@ describe('Icon', () => { it('renders an icon', () => { expect(icon).toMatchSnapshot(); }); + + it('listens to a click event', () => { + const clickListener = jest.fn() + const iconWithEvent = mount({ + name: 'IconWithEvent', + components: { AndroidIcon }, + template: ` + + `, + methods: { + clickListener, + }, + }) + + iconWithEvent.trigger('click') + expect(clickListener).not.toBeCalled() + }); }); From 3c6da0c0a7d43eee467a87e06cd6231cf44221d4 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 10 Sep 2019 13:11:35 +0100 Subject: [PATCH 2/2] fix: fix click event handler Closes #49 --- __tests__/icon.js | 2 +- template.mst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/icon.js b/__tests__/icon.js index 94d0c856..0d1dd8db 100644 --- a/__tests__/icon.js +++ b/__tests__/icon.js @@ -66,6 +66,6 @@ describe('Icon', () => { }) iconWithEvent.trigger('click') - expect(clickListener).not.toBeCalled() + expect(clickListener).toBeCalled() }); }); diff --git a/template.mst b/template.mst index 2737de9d..75117eb9 100644 --- a/template.mst +++ b/template.mst @@ -5,7 +5,7 @@ :class="[data.class, data.staticClass]" class="material-design-icon <%title%>-icon" role="img" - @click="listeners.click ? listeners.click : () => true"> + v-on="listeners">