mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
refactor(web): migrate to Vitest and esm (#29974)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
@ -6,8 +6,8 @@ import ConfirmModal from './index'
|
||||
// Test utilities
|
||||
const defaultProps = {
|
||||
show: true,
|
||||
onClose: jest.fn(),
|
||||
onConfirm: jest.fn(),
|
||||
onClose: vi.fn(),
|
||||
onConfirm: vi.fn(),
|
||||
}
|
||||
|
||||
const renderComponent = (props: Partial<React.ComponentProps<typeof ConfirmModal>> = {}) => {
|
||||
@ -17,7 +17,7 @@ const renderComponent = (props: Partial<React.ComponentProps<typeof ConfirmModal
|
||||
|
||||
describe('ConfirmModal', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
// Rendering tests (REQUIRED)
|
||||
@ -108,7 +108,7 @@ describe('ConfirmModal', () => {
|
||||
it('should call onClose when close button is clicked', async () => {
|
||||
// Arrange
|
||||
const user = userEvent.setup()
|
||||
const onClose = jest.fn()
|
||||
const onClose = vi.fn()
|
||||
renderComponent({ onClose })
|
||||
|
||||
// Act - Find the close button and click it
|
||||
@ -123,7 +123,7 @@ describe('ConfirmModal', () => {
|
||||
it('should call onClose when cancel button is clicked', async () => {
|
||||
// Arrange
|
||||
const user = userEvent.setup()
|
||||
const onClose = jest.fn()
|
||||
const onClose = vi.fn()
|
||||
renderComponent({ onClose })
|
||||
|
||||
// Act
|
||||
@ -137,7 +137,7 @@ describe('ConfirmModal', () => {
|
||||
it('should call onConfirm when confirm button is clicked', async () => {
|
||||
// Arrange
|
||||
const user = userEvent.setup()
|
||||
const onConfirm = jest.fn()
|
||||
const onConfirm = vi.fn()
|
||||
renderComponent({ onConfirm })
|
||||
|
||||
// Act
|
||||
@ -199,7 +199,7 @@ describe('ConfirmModal', () => {
|
||||
it('should handle multiple quick clicks on close button', async () => {
|
||||
// Arrange
|
||||
const user = userEvent.setup()
|
||||
const onClose = jest.fn()
|
||||
const onClose = vi.fn()
|
||||
renderComponent({ onClose })
|
||||
|
||||
const closeButton = document.querySelector('.cursor-pointer')
|
||||
@ -217,7 +217,7 @@ describe('ConfirmModal', () => {
|
||||
it('should handle multiple quick clicks on confirm button', async () => {
|
||||
// Arrange
|
||||
const user = userEvent.setup()
|
||||
const onConfirm = jest.fn()
|
||||
const onConfirm = vi.fn()
|
||||
renderComponent({ onConfirm })
|
||||
|
||||
// Act
|
||||
@ -233,7 +233,7 @@ describe('ConfirmModal', () => {
|
||||
it('should handle multiple quick clicks on cancel button', async () => {
|
||||
// Arrange
|
||||
const user = userEvent.setup()
|
||||
const onClose = jest.fn()
|
||||
const onClose = vi.fn()
|
||||
renderComponent({ onClose })
|
||||
|
||||
// Act - Click cancel button twice
|
||||
|
||||
Reference in New Issue
Block a user