Permalink
Browse files

bind method onButtonClick to the template of ClickMeButton

  • Loading branch information...
trollepierre committed May 6, 2017
1 parent 31ed02d commit a12fa30a5e7d795f4750a2a1eeef571499e0af31
Showing with 14 additions and 1 deletion.
  1. +1 −1 src/components/ClickMeButton.vue
  2. +13 −0 test/unit/specs/ClickMeButton.spec.js
@@ -1,6 +1,6 @@
<template>
<div class="clickMeButton">
<button>{{ message }}</button>
<button v-on:click="onButtonClick">{{ message }}</button>
</div>
</template>
@@ -32,11 +32,24 @@ describe('ClickMeButton.vue', () => {
it('should emit click ', () => {
// Given
sinon.spy(vm, '$emit')
// When
vm.onButtonClick()
// Then
vm.$emit.calledWith('buttonHasBeenClicked')
})
it('should emit an event when button is clicked', () => {
// given
sinon.spy(vm, '$emit')
const button = vm.$el.querySelector('button')
// when
button.click()
// then
vm.$emit.calledWith('buttonHasBeenClicked')
})
})
})

0 comments on commit a12fa30

Please sign in to comment.