diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-15 18:01:57 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-15 18:01:57 -0800 |
| commit | 50d01525ac9f67c5a3e680a3f807c204f6a1cdbd (patch) | |
| tree | 066df58d556ed8a7573f4bc8b7141a528957a3cf /frontend-vanilla/src/router.test.ts | |
| parent | c652ac6a2cd23ef29f48465be09c2b674783e8e9 (diff) | |
| download | neko-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.ts | 37 |
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'); + }); +}); |
