Skip to content

Commit 1f8ac7f

Browse files
committed
chore: one more test
1 parent feca93e commit 1f8ac7f

File tree

1 file changed

+27
-44
lines changed

1 file changed

+27
-44
lines changed

packages/vuetify/src/composables/__tests__/filter.spec.ts

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,10 @@ describe('filter', () => {
6464
value: (s: string) => s === '1',
6565
}
6666
const items = [
67-
{
68-
title: 'foo',
69-
subtitle: 'bar',
70-
value: '1',
71-
custom: '1',
72-
},
73-
{
74-
title: 'fizz',
75-
subtitle: 'buzz',
76-
value: '1',
77-
custom: 'bar',
78-
},
79-
{
80-
title: 'foobar',
81-
subtitle: 'fizzbuzz',
82-
value: '2',
83-
custom: 'bar',
84-
},
85-
{
86-
title: 'buzz',
87-
subtitle: 'buzz',
88-
value: '1',
89-
custom: 'buzz',
90-
},
67+
{ title: 'foo', subtitle: 'bar', value: '1', custom: '1' },
68+
{ title: 'fizz', subtitle: 'buzz', value: '1', custom: 'bar' },
69+
{ title: 'foobar', subtitle: 'fizzbuzz', value: '2', custom: 'bar' },
70+
{ title: 'buzz', subtitle: 'buzz', value: '1', custom: 'buzz' },
9171
] as any
9272
const filterKeys = ['title', 'value', 'subtitle', 'custom']
9373

@@ -122,26 +102,10 @@ describe('filter', () => {
122102
value: (s: string) => s === '1',
123103
}
124104
const items = [
125-
{
126-
title: 'foo',
127-
subtitle: 'bar',
128-
value: '1',
129-
},
130-
{
131-
title: 'fizz',
132-
subtitle: 'buzz',
133-
value: '1',
134-
},
135-
{
136-
title: 'foobar',
137-
subtitle: 'fizzbuzz',
138-
value: '2',
139-
},
140-
{
141-
title: 'buzz',
142-
subtitle: 'buzz',
143-
value: '2',
144-
},
105+
{ title: 'foo', subtitle: 'bar', value: '1' },
106+
{ title: 'fizz', subtitle: 'buzz', value: '1' },
107+
{ title: 'foobar', subtitle: 'fizzbuzz', value: '2' },
108+
{ title: 'buzz', subtitle: 'buzz', value: '2' },
145109
] as any
146110
const filterKeys = ['title', 'value']
147111

@@ -169,6 +133,25 @@ describe('filter', () => {
169133
filterMode: 'every',
170134
})).toHaveLength(2)
171135
})
136+
137+
// https://github.com/vuetifyjs/vuetify/pull/21876
138+
it('should return filtered rows when all columns have filters', () => {
139+
const customKeyFilter = {
140+
title: (s: string) => s.length < 5,
141+
subtitle: (s: string) => s.startsWith('b'),
142+
value: (s: any) => Number(s) > 0,
143+
}
144+
const items = [
145+
{ title: 'foo', subtitle: 'bar', value: 1 },
146+
{ title: 'fizz', subtitle: 'buzz', value: 1 },
147+
{ title: 'foobar', subtitle: 'fizzbuzz', value: 2 },
148+
] as any
149+
150+
expect(filterItems(items, '', {
151+
customKeyFilter,
152+
filterMode: 'intersection',
153+
})).toHaveLength(2)
154+
})
172155
})
173156

174157
describe('useFilter', () => {

0 commit comments

Comments
 (0)