tests: test if custom props are passed to custom connection line

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-03-08 16:32:11 +01:00
committed by Braks
parent 046ee41e79
commit 3f72713e3e
@@ -1,11 +1,17 @@
import { h } from 'vue' import { h } from 'vue'
import type { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import type { ConnectionLineProps } from '@vue-flow/core' import type { ConnectionLineProps, GraphNode, HandleElement } from '@vue-flow/core'
import { BaseEdge, getBezierPath } from '@vue-flow/core' import { BaseEdge, getBezierPath } from '@vue-flow/core'
let propTargetNode: GraphNode | null | undefined = null
let propTargetHandle: HandleElement | null | undefined = null
const CustomConnectionLine: FunctionalComponent<ConnectionLineProps> = (props: ConnectionLineProps) => { const CustomConnectionLine: FunctionalComponent<ConnectionLineProps> = (props: ConnectionLineProps) => {
const path = getBezierPath(props) const path = getBezierPath(props)
propTargetNode = props.targetNode
propTargetHandle = props.targetHandle
return h(BaseEdge, { path: path[0], class: 'test-custom-connection-line' }) return h(BaseEdge, { path: path[0], class: 'test-custom-connection-line' })
} }
@@ -13,7 +19,6 @@ describe('Check if custom connection lines are rendered', () => {
beforeEach(() => { beforeEach(() => {
cy.vueFlow( cy.vueFlow(
{ {
fitViewOnInit: false,
modelValue: [ modelValue: [
{ {
id: '1', id: '1',
@@ -54,14 +59,19 @@ describe('Check if custom connection lines are rendered', () => {
force: true, force: true,
}) })
cy.get('.test-custom-connection-line').should('have.length', 1) cy.get('.test-custom-connection-line')
.should('have.length', 1)
.then(() => {
expect(propTargetNode).to.not.be.null
expect(propTargetHandle).to.not.be.null
sourceHandle.trigger('mouseup', { sourceHandle.trigger('mouseup', {
clientX: x + 5, clientX: x + 5,
clientY: y + 5, clientY: y + 5,
force: true, force: true,
view: win, view: win,
}) })
})
}) })
}) })
}) })