mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 11:11:12 +08:00
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import React from 'react'
|
|
import { fireEvent, render, screen } from '@testing-library/react'
|
|
import FormattingChanged from './formatting-changed'
|
|
|
|
describe('FormattingChanged WarningMask', () => {
|
|
test('should display translation text and both actions', () => {
|
|
const onConfirm = vi.fn()
|
|
const onCancel = vi.fn()
|
|
|
|
render(
|
|
<FormattingChanged
|
|
onConfirm={onConfirm}
|
|
onCancel={onCancel}
|
|
/>,
|
|
)
|
|
|
|
expect(screen.getByText('appDebug.formattingChangedTitle')).toBeInTheDocument()
|
|
expect(screen.getByText('appDebug.formattingChangedText')).toBeInTheDocument()
|
|
expect(screen.getByRole('button', { name: 'common.operation.cancel' })).toBeInTheDocument()
|
|
expect(screen.getByRole('button', { name: /common\.operation\.refresh/ })).toBeInTheDocument()
|
|
})
|
|
|
|
test('should call callbacks when buttons are clicked', () => {
|
|
const onConfirm = vi.fn()
|
|
const onCancel = vi.fn()
|
|
render(
|
|
<FormattingChanged
|
|
onConfirm={onConfirm}
|
|
onCancel={onCancel}
|
|
/>,
|
|
)
|
|
|
|
fireEvent.click(screen.getByRole('button', { name: /common\.operation\.refresh/ }))
|
|
fireEvent.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
|
|
|
|
expect(onConfirm).toHaveBeenCalledTimes(1)
|
|
expect(onCancel).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|