import { describe, it, expect, beforeEach } from 'vitest' import { search } from '../../../src/lib/stores/search.js' describe('SearchStore', () => { beforeEach(() => { search.clear() }) describe('initial state', () => { it('should have empty query', () => { expect(search.query).toBe('') }) it('should have activeGroupId set to "all"', () => { expect(search.activeGroupId).toBe('all') }) }) describe('query', () => { it('should update query', () => { search.setSearchQuery('test') expect(search.query).toBe('test') }) it('should handle unicode query', () => { search.setSearchQuery('тест') expect(search.query).toBe('тест') }) }) describe('activeGroupId', () => { it('should update activeGroupId', () => { search.activeGroupId = 'group-123' expect(search.activeGroupId).toBe('group-123') }) it('should allow setting back to "all"', () => { search.activeGroupId = 'group-123' search.activeGroupId = 'all' expect(search.activeGroupId).toBe('all') }) it('should allow empty string for ungrouped', () => { search.activeGroupId = '' expect(search.activeGroupId).toBe('') }) }) describe('clear()', () => { it('should reset query to empty string', () => { search.setSearchQuery('some search') search.clear() expect(search.query).toBe('') }) it('should reset activeGroupId to "all"', () => { search.activeGroupId = 'group-123' search.clear() expect(search.activeGroupId).toBe('all') }) it('should reset both fields simultaneously', () => { search.setSearchQuery('some search') search.activeGroupId = 'group-123' search.clear() expect(search.query).toBe('') expect(search.activeGroupId).toBe('all') }) }) })