susanahernandezd
4/24/2019 - 4:34 PM

Test Emit

//.vue
<template>
  <button
    v-if="isSomeFilterSelected"
    type="button"
    class="btn btn-link clear-filters"
    @click="clearFilters"
  >x {{translate('desClearAllFilters')}}</button>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'

export default {
  name: 'ClearFilters',
  computed: {
    ...mapGetters(['isSomeFilterSelected'])
  },
  methods: {
    ...mapActions(['resetFilters']),
    clearFilters () {
      this.resetFilters()
      this.$emit('resetFilters')
    }
  }
}
</script>

//test
it('resets filters', () => {
    wrapper.find('.clear-filters').trigger('click')

    expect(wrapper.emitted().resetFilters).toBeTruthy()
    expect(actions.resetFilters).toHaveBeenCalled()
  })