|
1 | 1 | import { describe, expect, it } from 'vitest' |
2 | 2 | import { |
3 | | - formatSearchOperators, |
4 | 3 | hasSearchOperators, |
5 | 4 | parseSearchOperators, |
6 | | - type ParsedSearchOperators, |
7 | 5 | } from '../../app/composables/useStructuredFilters' |
8 | 6 |
|
9 | 7 | describe('parseSearchOperators', () => { |
@@ -161,54 +159,6 @@ describe('parseSearchOperators', () => { |
161 | 159 | }) |
162 | 160 | }) |
163 | 161 |
|
164 | | -describe('formatSearchOperators', () => { |
165 | | - it('formats name operator', () => { |
166 | | - const parsed: ParsedSearchOperators = { name: ['react'] } |
167 | | - expect(formatSearchOperators(parsed)).toBe('name:react') |
168 | | - }) |
169 | | - |
170 | | - it('formats description operator as desc', () => { |
171 | | - const parsed: ParsedSearchOperators = { description: ['framework'] } |
172 | | - expect(formatSearchOperators(parsed)).toBe('desc:framework') |
173 | | - }) |
174 | | - |
175 | | - it('formats keywords operator as kw', () => { |
176 | | - const parsed: ParsedSearchOperators = { keywords: ['typescript'] } |
177 | | - expect(formatSearchOperators(parsed)).toBe('kw:typescript') |
178 | | - }) |
179 | | - |
180 | | - it('formats multiple values with commas', () => { |
181 | | - const parsed: ParsedSearchOperators = { keywords: ['react', 'hooks', 'state'] } |
182 | | - expect(formatSearchOperators(parsed)).toBe('kw:react,hooks,state') |
183 | | - }) |
184 | | - |
185 | | - it('formats multiple operators with spaces', () => { |
186 | | - const parsed: ParsedSearchOperators = { |
187 | | - name: ['react'], |
188 | | - keywords: ['typescript'], |
189 | | - } |
190 | | - expect(formatSearchOperators(parsed)).toBe('name:react kw:typescript') |
191 | | - }) |
192 | | - |
193 | | - it('includes remaining text at end', () => { |
194 | | - const parsed: ParsedSearchOperators = { |
195 | | - name: ['react'], |
196 | | - text: 'some text', |
197 | | - } |
198 | | - expect(formatSearchOperators(parsed)).toBe('name:react some text') |
199 | | - }) |
200 | | - |
201 | | - it('returns only text when no operators', () => { |
202 | | - const parsed: ParsedSearchOperators = { text: 'search query' } |
203 | | - expect(formatSearchOperators(parsed)).toBe('search query') |
204 | | - }) |
205 | | - |
206 | | - it('returns empty string for empty object', () => { |
207 | | - const parsed: ParsedSearchOperators = {} |
208 | | - expect(formatSearchOperators(parsed)).toBe('') |
209 | | - }) |
210 | | -}) |
211 | | - |
212 | 162 | describe('hasSearchOperators', () => { |
213 | 163 | it('returns true when name is present', () => { |
214 | 164 | expect(hasSearchOperators({ name: ['react'] })).toBe(true) |
@@ -238,17 +188,3 @@ describe('hasSearchOperators', () => { |
238 | 188 | expect(hasSearchOperators({ name: [], keywords: [] })).toBe(false) |
239 | 189 | }) |
240 | 190 | }) |
241 | | - |
242 | | -describe('parseSearchOperators roundtrip', () => { |
243 | | - it.each([ |
244 | | - 'name:react', |
245 | | - 'kw:typescript,hooks', |
246 | | - 'name:react kw:typescript', |
247 | | - 'name:react desc:framework kw:hooks', |
248 | | - ])('roundtrips "%s" correctly', input => { |
249 | | - const parsed = parseSearchOperators(input) |
250 | | - const formatted = formatSearchOperators(parsed) |
251 | | - // The formatted output should parse to the same result |
252 | | - expect(parseSearchOperators(formatted)).toEqual(parsed) |
253 | | - }) |
254 | | -}) |
0 commit comments