Skip to content

Commit 17c28a7

Browse files
committed
tests: add custom node test
Signed-off-by: braks <[email protected]>
1 parent 3211686 commit 17c28a7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { NodeComponent } from '@vue-flow/core'
2+
import { Handle } from '@vue-flow/core'
3+
import { defineComponent, h, markRaw } from 'vue'
4+
5+
const CustomNode: NodeComponent = defineComponent(() => {
6+
return () =>
7+
h('div', { class: 'vue-flow__node-default' }, [
8+
h(Handle as any, { id: 'handle-1', position: 'left', type: 'target', style: { top: '5px' } }),
9+
h(Handle as any, { id: 'handle-2', position: 'left', type: 'target', style: { bottom: '-10px' } }),
10+
'Custom Node',
11+
h(Handle as any, { id: 'handle-3', position: 'right' }),
12+
])
13+
})
14+
15+
describe('Check if custom nodes are rendered', () => {
16+
beforeEach(() => {
17+
cy.vueFlow({
18+
fitViewOnInit: false,
19+
modelValue: [
20+
{
21+
id: '1',
22+
label: 'Node 1',
23+
position: { x: 0, y: 0 },
24+
},
25+
{
26+
id: '2',
27+
type: 'custom',
28+
label: 'Node 2',
29+
position: { x: 300, y: 300 },
30+
},
31+
],
32+
nodeTypes: {
33+
custom: markRaw(CustomNode),
34+
},
35+
autoConnect: true,
36+
})
37+
})
38+
39+
it('renders custom node', () => {
40+
cy.get('.vue-flow__node-custom').should('have.length', 1)
41+
})
42+
})

0 commit comments

Comments
 (0)