//.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()
})