mirror of
https://github.com/langgenius/dify.git
synced 2026-08-28 19:38:30 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: fatelei <fatelei@gmail.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { hasSearchText, isSearchResultEmpty } from '../search-state'
|
|
|
|
describe('search-state', () => {
|
|
it('detects trimmed search text', () => {
|
|
expect(hasSearchText(' query ')).toBe(true)
|
|
expect(hasSearchText(' ')).toBe(false)
|
|
expect(hasSearchText()).toBe(false)
|
|
})
|
|
|
|
it('treats search empty as filtering existing source data to no results', () => {
|
|
expect(isSearchResultEmpty({
|
|
isLoading: false,
|
|
resultCount: 0,
|
|
searchText: 'missing',
|
|
sourceCount: 2,
|
|
})).toBe(true)
|
|
})
|
|
|
|
it('does not treat loading or true source empty as search empty', () => {
|
|
expect(isSearchResultEmpty({
|
|
isLoading: true,
|
|
resultCount: 0,
|
|
searchText: 'missing',
|
|
sourceCount: 2,
|
|
})).toBe(false)
|
|
expect(isSearchResultEmpty({
|
|
isLoading: false,
|
|
resultCount: 0,
|
|
searchText: 'missing',
|
|
sourceCount: 0,
|
|
})).toBe(false)
|
|
})
|
|
|
|
it('supports non-text filters', () => {
|
|
expect(isSearchResultEmpty({
|
|
hasActiveFilter: true,
|
|
isLoading: false,
|
|
resultCount: 0,
|
|
sourceCount: 2,
|
|
})).toBe(true)
|
|
})
|
|
})
|