mirror of
https://github.com/langgenius/dify.git
synced 2026-03-21 22:38:26 +08:00
Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { Node } from '../types'
|
|
import { screen } from '@testing-library/react'
|
|
import CandidateNode from '../candidate-node'
|
|
import { BlockEnum } from '../types'
|
|
import { renderWorkflowComponent } from './workflow-test-env'
|
|
|
|
vi.mock('../candidate-node-main', () => ({
|
|
default: ({ candidateNode }: { candidateNode: Node }) => (
|
|
<div data-testid="candidate-node-main">{candidateNode.id}</div>
|
|
),
|
|
}))
|
|
|
|
const createCandidateNode = (): Node => ({
|
|
id: 'candidate-node-1',
|
|
type: 'custom',
|
|
position: { x: 0, y: 0 },
|
|
data: {
|
|
type: BlockEnum.Start,
|
|
title: 'Candidate node',
|
|
desc: 'candidate',
|
|
},
|
|
})
|
|
|
|
describe('CandidateNode', () => {
|
|
it('should not render when candidateNode is missing from the workflow store', () => {
|
|
renderWorkflowComponent(<CandidateNode />)
|
|
|
|
expect(screen.queryByTestId('candidate-node-main')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('should render CandidateNodeMain with the stored candidate node', () => {
|
|
renderWorkflowComponent(<CandidateNode />, {
|
|
initialStoreState: {
|
|
candidateNode: createCandidateNode(),
|
|
},
|
|
})
|
|
|
|
expect(screen.getByTestId('candidate-node-main')).toHaveTextContent('candidate-node-1')
|
|
})
|
|
})
|