aboutsummaryrefslogtreecommitdiffstats
path: root/frontend-vanilla/src/store.test.ts
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-15 17:44:55 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-15 17:44:55 -0800
commitc652ac6a2cd23ef29f48465be09c2b674783e8e9 (patch)
treec5c05a71a1d5b8155b05dad4a512b18ff7258f47 /frontend-vanilla/src/store.test.ts
parent90c1a68d6478138f538094fc83e48da8ddd21fa0 (diff)
downloadneko-c652ac6a2cd23ef29f48465be09c2b674783e8e9.tar.gz
neko-c652ac6a2cd23ef29f48465be09c2b674783e8e9.tar.bz2
neko-c652ac6a2cd23ef29f48465be09c2b674783e8e9.zip
Vanilla JS (v3): Implement 3-pane layout, item fetching, reading, and testing
Diffstat (limited to 'frontend-vanilla/src/store.test.ts')
-rw-r--r--frontend-vanilla/src/store.test.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/frontend-vanilla/src/store.test.ts b/frontend-vanilla/src/store.test.ts
new file mode 100644
index 0000000..688e43e
--- /dev/null
+++ b/frontend-vanilla/src/store.test.ts
@@ -0,0 +1,48 @@
+import { describe, it, expect, vi } from 'vitest';
+import { Store } from './store';
+
+describe('Store', () => {
+ it('should store and notify about feeds', () => {
+ const store = new Store();
+ const mockFeeds = [
+ { _id: 1, title: 'Feed 1', url: 'http://1', web_url: 'http://1', category: 'cat' }
+ ];
+
+ const callback = vi.fn();
+ store.addEventListener('feeds-updated', callback);
+
+ store.setFeeds(mockFeeds);
+
+ expect(store.feeds).toEqual(mockFeeds);
+ expect(callback).toHaveBeenCalled();
+ });
+
+ it('should handle items and loading state', () => {
+ const store = new Store();
+ const mockItems = [{ _id: 1, title: 'Item 1' } as any];
+
+ const itemCallback = vi.fn();
+ const loadingCallback = vi.fn();
+
+ store.addEventListener('items-updated', itemCallback);
+ store.addEventListener('loading-state-changed', loadingCallback);
+
+ store.setLoading(true);
+ expect(store.loading).toBe(true);
+ expect(loadingCallback).toHaveBeenCalled();
+
+ store.setItems(mockItems);
+ expect(store.items).toEqual(mockItems);
+ expect(itemCallback).toHaveBeenCalled();
+ });
+
+ it('should notify when active feed changes', () => {
+ const store = new Store();
+ const callback = vi.fn();
+ store.addEventListener('active-feed-updated', callback);
+
+ store.setActiveFeed(123);
+ expect(store.activeFeedId).toBe(123);
+ expect(callback).toHaveBeenCalled();
+ });
+});