fix(test): 修复 CopyButton mock 未捕获 clipboard writeText 异常
This commit is contained in:
+5
-1
@@ -80,7 +80,11 @@ vi.mock('@/components/CopyButton', () => ({
|
||||
type: 'button',
|
||||
onClick: async (e: React.MouseEvent) => {
|
||||
if (text) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} catch {
|
||||
// 与真实 CopyButton 行为一致:失败时静默处理
|
||||
}
|
||||
}
|
||||
onClick?.(e);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user