aboutsummaryrefslogtreecommitdiffstats
path: root/frontend-vanilla/src/router.test.ts
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-15 18:01:57 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-15 18:01:57 -0800
commit50d01525ac9f67c5a3e680a3f807c204f6a1cdbd (patch)
tree066df58d556ed8a7573f4bc8b7141a528957a3cf /frontend-vanilla/src/router.test.ts
parentc652ac6a2cd23ef29f48465be09c2b674783e8e9 (diff)
downloadneko-50d01525ac9f67c5a3e680a3f807c204f6a1cdbd.tar.gz
neko-50d01525ac9f67c5a3e680a3f807c204f6a1cdbd.tar.bz2
neko-50d01525ac9f67c5a3e680a3f807c204f6a1cdbd.zip
Vanilla JS (v3): Implement Tags, Filters, and Infinite Scroll
Diffstat (limited to 'frontend-vanilla/src/router.test.ts')
-rw-r--r--frontend-vanilla/src/router.test.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/frontend-vanilla/src/router.test.ts b/frontend-vanilla/src/router.test.ts
new file mode 100644
index 0000000..d79abc1
--- /dev/null
+++ b/frontend-vanilla/src/router.test.ts
@@ -0,0 +1,37 @@
+import { describe, it, expect, vi } from 'vitest';
+import { router } from './router';
+
+describe('Router', () => {
+ it('should parse simple paths', () => {
+ // Mock window.location
+ vi.stubGlobal('location', {
+ href: 'http://localhost/v3/feed/123',
+ pathname: '/v3/feed/123'
+ });
+
+ const route = router.getCurrentRoute();
+ expect(route.path).toBe('/feed');
+ expect(route.params.feedId).toBe('123');
+ });
+
+ it('should parse tags correctly', () => {
+ vi.stubGlobal('location', {
+ href: 'http://localhost/v3/tag/Tech%20News',
+ pathname: '/v3/tag/Tech%20News'
+ });
+
+ const route = router.getCurrentRoute();
+ expect(route.path).toBe('/tag');
+ expect(route.params.tagName).toBe('Tech News');
+ });
+
+ it('should parse query parameters', () => {
+ vi.stubGlobal('location', {
+ href: 'http://localhost/v3/?filter=starred',
+ pathname: '/v3/'
+ });
+
+ const route = router.getCurrentRoute();
+ expect(route.query.get('filter')).toBe('starred');
+ });
+});