Reputation: 7150
I have a Single File Component with a filter defined
filters: {
capitalize: function (value) {
if (!value) return ''
value = value.toString()
return value.charAt(0).toUpperCase() + value.slice(1)
}
},
I thought I could simply test it like
it('should capitalize input', () => {
const wrapper = shallowMount(MyComp)
expect(wrapper.vm.capitalize('foo')).toEqual('Foo')
// or
expect(wrapper.vm.filters.capitalize('foo')).toEqual('Foo')
})
but apparently I can't access a filter function like that directly and for some reason I cannot find in the docs how to do it correctly?
Upvotes: 2
Views: 725