diff --git a/public/router.js b/public/router.js index edbf73d..48492af 100644 --- a/public/router.js +++ b/public/router.js @@ -24,6 +24,8 @@ const ROUTES = [ { name: 'yerin', re: /^\/(yerin|sentinel)$/, keys: [] }, { name: 'little-blue', re: /^\/little-blue$/, keys: [] }, { name: 'terminal', re: /^\/terminal$/, keys: [] }, + { name: 'timelapse', re: /^\/timelapse$/, keys: [] }, + { name: 'ai-usage', re: /^\/ai-usage$/, keys: [] }, { name: 'settings', re: /^\/settings$/, keys: [] }, { name: 'jobs', re: /^\/jobs$/, keys: [] }, { name: 'home', re: /^\/?$/, keys: [] } diff --git a/tests/frontend/router.test.js b/tests/frontend/router.test.js new file mode 100644 index 0000000..8e23783 --- /dev/null +++ b/tests/frontend/router.test.js @@ -0,0 +1,15 @@ +import { describe, it, expect, beforeAll, afterAll } from 'vitest'; +import { JSDOM } from 'jsdom'; + +let current; +beforeAll(async () => { + const dom = new JSDOM('', { url: 'http://localhost/#/' }); + global.window = dom.window; global.document = dom.window.document; global.location = dom.window.location; + ({ current } = await import('../../public/router.js')); +}); +afterAll(() => { delete global.window; delete global.document; delete global.location; }); + +describe('router app routes', () => { + it('resolves #/timelapse', () => { location.hash = '#/timelapse'; expect(current().name).toBe('timelapse'); }); + it('resolves #/ai-usage', () => { location.hash = '#/ai-usage'; expect(current().name).toBe('ai-usage'); }); +});