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,27 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { encodeQr } from './qr';
|
||||
import { QR_ALL_MASKS, QR_FIXTURES } from './qr.fixtures';
|
||||
|
||||
const toRows = (grid: boolean[][]) => grid.map((r) => r.map((c) => (c ? '1' : '0')).join(''));
|
||||
|
||||
describe('encodeQr', () => {
|
||||
// 参考矩阵来自 Python qrcode(纠错 M、字节模式)。逐模块一致,说明版本选择、
|
||||
// Reed-Solomon、交错、功能图形、格式位与版本位(v7+)都正确
|
||||
it.each(Object.entries(QR_FIXTURES))('与参考实现逐模块一致:%s', (_name, fx) => {
|
||||
expect(toRows(encodeQr(fx.text, fx.mask))).toEqual(fx.rows);
|
||||
});
|
||||
|
||||
it('自动选掩码:结果必须等于参考实现 8 种掩码之一(验证掩码应用与还原)', () => {
|
||||
const got = toRows(encodeQr(QR_ALL_MASKS.text)).join('|');
|
||||
expect(QR_ALL_MASKS.rows.map((r) => r.join('|'))).toContain(got);
|
||||
});
|
||||
|
||||
it('自动选择掩码时,尺寸与版本一致', () => {
|
||||
const fx = QR_FIXTURES.member;
|
||||
expect(encodeQr(fx.text)).toHaveLength(fx.rows.length);
|
||||
});
|
||||
|
||||
it('内容太长时抛错', () => {
|
||||
expect(() => encodeQr('x'.repeat(300))).toThrow(RangeError);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user