aboutsummaryrefslogtreecommitdiffstats
path: root/frontend-vanilla/src/store.test.ts
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-15 19:36:03 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-15 19:36:03 -0800
commit59743dcaa87920a5125915454e0afa0a22b05ee7 (patch)
tree11666ff75c615face8dee0f479d0b3c7c79bb187 /frontend-vanilla/src/store.test.ts
parenta113bc13e569049c59baa2165d28a992d7bdde7b (diff)
downloadneko-59743dcaa87920a5125915454e0afa0a22b05ee7.tar.gz
neko-59743dcaa87920a5125915454e0afa0a22b05ee7.tar.bz2
neko-59743dcaa87920a5125915454e0afa0a22b05ee7.zip
Vanilla JS (v3): Redesign to 2-pane glassmorphism, fix CSP errors, fix Settings view, and achieve 80% test coverage
Diffstat (limited to 'frontend-vanilla/src/store.test.ts')
-rw-r--r--frontend-vanilla/src/store.test.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/frontend-vanilla/src/store.test.ts b/frontend-vanilla/src/store.test.ts
index ccf9a1d..33deb7f 100644
--- a/frontend-vanilla/src/store.test.ts
+++ b/frontend-vanilla/src/store.test.ts
@@ -17,6 +17,20 @@ describe('Store', () => {
expect(callback).toHaveBeenCalled();
});
+ it('should handle tags', () => {
+ const store = new Store();
+ const mockTags = [{ title: 'Tag 1' } as any];
+ const callback = vi.fn();
+ store.on('tags-updated', callback);
+
+ store.setTags(mockTags);
+ expect(store.tags).toEqual(mockTags);
+ expect(callback).toHaveBeenCalled();
+
+ store.setActiveTag('Tag 1');
+ expect(store.activeTagName).toBe('Tag 1');
+ });
+
it('should handle items and loading state', () => {
const store = new Store();
const mockItems = [{ _id: 1, title: 'Item 1' } as any];
@@ -34,6 +48,20 @@ describe('Store', () => {
store.setItems(mockItems);
expect(store.items).toEqual(mockItems);
expect(itemCallback).toHaveBeenCalled();
+
+ // Test append
+ const moreItems = [{ _id: 2, title: 'Item 2' } as any];
+ store.setItems(moreItems, true);
+ expect(store.items).toHaveLength(2);
+ expect(store.items[1]._id).toBe(2);
+ });
+
+ it('should handle pagination state', () => {
+ const store = new Store();
+ store.setHasMore(true);
+ expect(store.hasMore).toBe(true);
+ store.setHasMore(false);
+ expect(store.hasMore).toBe(false);
});
it('should notify when active feed changes', () => {
@@ -66,4 +94,15 @@ describe('Store', () => {
expect(localStorage.getItem('neko-theme')).toBe('dark');
expect(callback).toHaveBeenCalled();
});
+
+ it('should handle font theme changes', () => {
+ const store = new Store();
+ const callback = vi.fn();
+ store.on('theme-updated', callback);
+
+ store.setFontTheme('serif');
+ expect(store.fontTheme).toBe('serif');
+ expect(localStorage.getItem('neko-font-theme')).toBe('serif');
+ expect(callback).toHaveBeenCalled();
+ });
});