This commit is contained in:
33
website/tests/unit/router.test.js
Normal file
33
website/tests/unit/router.test.js
Normal file
@ -0,0 +1,33 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
|
||||
import { navigate, currentHash, matchRoute } from '../../js/router.js';
|
||||
|
||||
|
||||
|
||||
describe('router', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
window.location.hash = '';
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('currentHash defaults to / when empty', () => {
|
||||
|
||||
window.location.hash = '';
|
||||
|
||||
expect(currentHash()).toBe('/');
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('currentHash strips leading hash', () => {
|
||||
|
||||
window.location.hash = '#/dashboard';
|
||||
|
||||
expect(currentHash()).toBe('/dashboard');
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user