[新增] 集成 Sonner 通知库,添加 Toaster 组件并在 InlineMessage 中使用

This commit is contained in:
ryan
2026-06-01 10:41:54 +08:00
parent f034b73a47
commit 65f899d334
15 changed files with 1775 additions and 4792 deletions
@@ -1 +1,26 @@
import '@testing-library/jest-dom/vitest';
import { vi } from 'vitest';
const toastMock = vi.fn((msg) => {
const el = document.createElement('div');
el.textContent = typeof msg === 'string' ? msg : '';
document.body.appendChild(el);
return 'toast-id';
});
vi.mock('sonner', () => ({
toast: Object.assign(toastMock, {
success: vi.fn((msg) => {
const el = document.createElement('div');
el.textContent = typeof msg === 'string' ? msg : '';
document.body.appendChild(el);
return 'toast-id';
}),
error: vi.fn((msg) => {
const el = document.createElement('div');
el.textContent = typeof msg === 'string' ? msg : '';
document.body.appendChild(el);
return 'toast-id';
}),
}),
}));