feat(web): connect quick share flow
Signed-off-by: JustMe <mr.toing@outlook.com>
This commit is contained in:
1 parent
53768a195d
commit
e02e024605
138 files changed
+10614
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
// navigation.ts 在模块加载时读 location/window,这里只测纯函数,用最小的桩
|
||||
Object.assign(globalThis, {
|
||||
location: { pathname: '/', origin: 'http://x' },
|
||||
window: { addEventListener: () => {} },
|
||||
history: { state: null },
|
||||
});
|
||||
|
||||
const { parseRoute } = await import('./navigation');
|
||||
|
||||
describe('parseRoute', () => {
|
||||
it('根路径是首页', () => expect(parseRoute('/')).toEqual({ name: 'home' }));
|
||||
it('/c/:id 是频道', () => {
|
||||
expect(parseRoute('/c/k3Fq9xWm2LpA7sTdQ8vZ1n')).toEqual({ name: 'channel', id: 'k3Fq9xWm2LpA7sTdQ8vZ1n' });
|
||||
});
|
||||
it('/s/:id 是便捷分享', () => {
|
||||
expect(parseRoute('/s/k3Fq9xWm2LpA7sTdQ8vZ1n')).toEqual({ name: 'share', id: 'k3Fq9xWm2LpA7sTdQ8vZ1n' });
|
||||
});
|
||||
it('id 格式不对回到首页', () => expect(parseRoute('/c/short')).toEqual({ name: 'home' }));
|
||||
it('未知路径回到首页', () => expect(parseRoute('/other')).toEqual({ name: 'home' }));
|
||||
});
|
||||
Reference in new issue
Block a user