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,35 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseChannelLink } from './channelLink';
|
||||
|
||||
const ID = 'k3Fq9xWm2LpA7sTdQ8vZ1n';
|
||||
const KEY = 'Zm9vYmFyYmF6cXV4Zm9vYmFyYmF6cXV4Zm9vYmFyYmF';
|
||||
|
||||
describe('parseChannelLink', () => {
|
||||
it('成员链接:带 k 即 enc', () => {
|
||||
const r = parseChannelLink(`https://webdrop.example/c/${ID}#k=${KEY}`);
|
||||
expect(r).toMatchObject({ ok: true, link: { id: ID, mode: 'enc', isOwner: false } });
|
||||
});
|
||||
|
||||
it('所有者链接:带 a', () => {
|
||||
const r = parseChannelLink(`https://webdrop.example/c/${ID}#k=${KEY}&a=${KEY}`);
|
||||
expect(r).toMatchObject({ ok: true, link: { mode: 'enc', isOwner: true } });
|
||||
});
|
||||
|
||||
it('不带 k 即 raw;带 w 表示可上传', () => {
|
||||
const r = parseChannelLink(`https://webdrop.example/c/${ID}#w=${KEY}`);
|
||||
expect(r).toMatchObject({ ok: true, link: { mode: 'raw', canWrite: true } });
|
||||
});
|
||||
|
||||
it('忽略首尾空白', () => {
|
||||
expect(parseChannelLink(` https://x.example/c/${ID} `).ok).toBe(true);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['不是链接', 'hello', 'bad_url'],
|
||||
['路径不对', `https://x.example/other/${ID}`, 'bad_url'],
|
||||
['id 长度不对', 'https://x.example/c/abc', 'bad_id'],
|
||||
['密钥长度不对', `https://x.example/c/${ID}#k=short`, 'bad_key'],
|
||||
])('%s → %s', (_n, input, error) => {
|
||||
expect(parseChannelLink(input)).toEqual({ ok: false, error });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user