[Vuejs]-How to test vue component passing method

0👍

Here is an excerpt from the unit tests:

it('methods', function () {
  var spy = jasmine.createSpy()
  var vm = new Vue({
    el: el,
    template: '<a v-on:click="test"></a>',
    data: {a: 1},
    methods: {
      test: spy
    }
  })
  var a = el.firstChild
  trigger(a, 'click')
  expect(spy.calls.count()).toBe(1)
  vm.$destroy()
  trigger(a, 'click')
  expect(spy.calls.count()).toBe(1)
})

Leave a comment