From 47750233ba7342de341e85af7b5d1492e9a035a8 Mon Sep 17 00:00:00 2001 From: Steven Kalt Date: Thu, 26 Oct 2017 12:45:12 -0400 Subject: [PATCH] added test of custom filter function --- test/unit/specs/Select.spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/unit/specs/Select.spec.js b/test/unit/specs/Select.spec.js index 05cbdaf..fea4e78 100644 --- a/test/unit/specs/Select.spec.js +++ b/test/unit/specs/Select.spec.js @@ -312,6 +312,18 @@ describe('Select.vue', () => { vm.$refs.select.search = 'ba' expect(JSON.stringify(vm.$refs.select.filteredOptions)).toEqual(JSON.stringify([{label: 'Bar', value: 'bar'}, {label: 'Baz', value: 'baz'}])) }) + + it('can use a custom filterFunction passed via props', ()=>{ + const vm = new Vue({ + template: `
`, + data: {value: 'foo'}, + methods:{ + customFn: (option, label, search) => label.match(new RegExp('^' + search, 'i')) + } + }).$mount() + vm.$refs.select.search = 'a' + expect(JSON.stringify(vm.$refs.select.filteredOptions)).toEqual(JSON.stringify([{label: 'Aoo', value: 'foo'}])) + }) }) describe('Toggling Dropdown', () => {