diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-15 18:05:38 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-15 18:05:38 -0800 |
| commit | a113bc13e569049c59baa2165d28a992d7bdde7b (patch) | |
| tree | 8a8ef4d856503c3c834b83b288faaa88ffc1b009 /frontend-vanilla/src/store.test.ts | |
| parent | 50d01525ac9f67c5a3e680a3f807c204f6a1cdbd (diff) | |
| download | neko-a113bc13e569049c59baa2165d28a992d7bdde7b.tar.gz neko-a113bc13e569049c59baa2165d28a992d7bdde7b.tar.bz2 neko-a113bc13e569049c59baa2165d28a992d7bdde7b.zip | |
Vanilla JS (v3): Final parity with React (Search, Settings, Shortcuts)
Diffstat (limited to 'frontend-vanilla/src/store.test.ts')
| -rw-r--r-- | frontend-vanilla/src/store.test.ts | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/frontend-vanilla/src/store.test.ts b/frontend-vanilla/src/store.test.ts index 688e43e..ccf9a1d 100644 --- a/frontend-vanilla/src/store.test.ts +++ b/frontend-vanilla/src/store.test.ts @@ -9,7 +9,7 @@ describe('Store', () => { ]; const callback = vi.fn(); - store.addEventListener('feeds-updated', callback); + store.on('feeds-updated', callback); store.setFeeds(mockFeeds); @@ -24,8 +24,8 @@ describe('Store', () => { const itemCallback = vi.fn(); const loadingCallback = vi.fn(); - store.addEventListener('items-updated', itemCallback); - store.addEventListener('loading-state-changed', loadingCallback); + store.on('items-updated', itemCallback); + store.on('loading-state-changed', loadingCallback); store.setLoading(true); expect(store.loading).toBe(true); @@ -39,10 +39,31 @@ describe('Store', () => { it('should notify when active feed changes', () => { const store = new Store(); const callback = vi.fn(); - store.addEventListener('active-feed-updated', callback); + store.on('active-feed-updated', callback); store.setActiveFeed(123); expect(store.activeFeedId).toBe(123); expect(callback).toHaveBeenCalled(); }); + + it('should handle search query', () => { + const store = new Store(); + const callback = vi.fn(); + store.on('search-updated', callback); + + store.setSearchQuery('test query'); + expect(store.searchQuery).toBe('test query'); + expect(callback).toHaveBeenCalled(); + }); + + it('should handle theme changes', () => { + const store = new Store(); + const callback = vi.fn(); + store.on('theme-updated', callback); + + store.setTheme('dark'); + expect(store.theme).toBe('dark'); + expect(localStorage.getItem('neko-theme')).toBe('dark'); + expect(callback).toHaveBeenCalled(); + }); }); |
