Skip to content

Commit 8d773b7

Browse files
committed
refactor: remove unused function
1 parent 5c36c14 commit 8d773b7

2 files changed

Lines changed: 0 additions & 86 deletions

File tree

app/composables/useStructuredFilters.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,28 +79,6 @@ export function parseSearchOperators(input: string): ParsedSearchOperators {
7979
return result
8080
}
8181

82-
/**
83-
* Format parsed operators back to string representation
84-
*/
85-
export function formatSearchOperators(parsed: ParsedSearchOperators): string {
86-
const parts: string[] = []
87-
88-
if (parsed.name?.length) {
89-
parts.push(`name:${parsed.name.join(',')}`)
90-
}
91-
if (parsed.description?.length) {
92-
parts.push(`desc:${parsed.description.join(',')}`)
93-
}
94-
if (parsed.keywords?.length) {
95-
parts.push(`kw:${parsed.keywords.join(',')}`)
96-
}
97-
if (parsed.text) {
98-
parts.push(parsed.text)
99-
}
100-
101-
return parts.join(' ')
102-
}
103-
10482
/**
10583
* Check if parsed operators has any content
10684
*/

test/unit/search-operators.spec.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { describe, expect, it } from 'vitest'
22
import {
3-
formatSearchOperators,
43
hasSearchOperators,
54
parseSearchOperators,
6-
type ParsedSearchOperators,
75
} from '../../app/composables/useStructuredFilters'
86

97
describe('parseSearchOperators', () => {
@@ -161,54 +159,6 @@ describe('parseSearchOperators', () => {
161159
})
162160
})
163161

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-
212162
describe('hasSearchOperators', () => {
213163
it('returns true when name is present', () => {
214164
expect(hasSearchOperators({ name: ['react'] })).toBe(true)
@@ -238,17 +188,3 @@ describe('hasSearchOperators', () => {
238188
expect(hasSearchOperators({ name: [], keywords: [] })).toBe(false)
239189
})
240190
})
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

Comments
 (0)