feat(platform-web): support shareable vehicle routes
This commit is contained in:
25
vehicle-data-platform/apps/web/src/domain/appRoute.test.ts
Normal file
25
vehicle-data-platform/apps/web/src/domain/appRoute.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { buildAppHash, parseAppHash } from './appRoute';
|
||||
|
||||
describe('parseAppHash', () => {
|
||||
test('parses detail page keyword from hash query', () => {
|
||||
expect(parseAppHash('#/detail?keyword=%E7%B2%A4AG18312')).toEqual({
|
||||
page: 'detail',
|
||||
keyword: '粤AG18312'
|
||||
});
|
||||
});
|
||||
|
||||
test('ignores unknown pages', () => {
|
||||
expect(parseAppHash('#/unknown?keyword=VIN001')).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildAppHash', () => {
|
||||
test('builds shareable vehicle page hash with encoded keyword', () => {
|
||||
expect(buildAppHash({ page: 'history', keyword: '粤AG18312' })).toBe('#/history?keyword=%E7%B2%A4AG18312');
|
||||
});
|
||||
|
||||
test('builds page-only hash when keyword is empty', () => {
|
||||
expect(buildAppHash({ page: 'quality', keyword: '' })).toBe('#/quality');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user