From 17c28a7b6dbf73768a5d002160ddb7cdae78e08e Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 23 Feb 2023 14:59:38 +0100 Subject: [PATCH] tests: add custom node test Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --- .../component/2-vue-flow/customNode.cy.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/cypress/component/2-vue-flow/customNode.cy.ts diff --git a/tests/cypress/component/2-vue-flow/customNode.cy.ts b/tests/cypress/component/2-vue-flow/customNode.cy.ts new file mode 100644 index 00000000..99a38960 --- /dev/null +++ b/tests/cypress/component/2-vue-flow/customNode.cy.ts @@ -0,0 +1,42 @@ +import type { NodeComponent } from '@vue-flow/core' +import { Handle } from '@vue-flow/core' +import { defineComponent, h, markRaw } from 'vue' + +const CustomNode: NodeComponent = defineComponent(() => { + return () => + h('div', { class: 'vue-flow__node-default' }, [ + h(Handle as any, { id: 'handle-1', position: 'left', type: 'target', style: { top: '5px' } }), + h(Handle as any, { id: 'handle-2', position: 'left', type: 'target', style: { bottom: '-10px' } }), + 'Custom Node', + h(Handle as any, { id: 'handle-3', position: 'right' }), + ]) +}) + +describe('Check if custom nodes are rendered', () => { + beforeEach(() => { + cy.vueFlow({ + fitViewOnInit: false, + modelValue: [ + { + id: '1', + label: 'Node 1', + position: { x: 0, y: 0 }, + }, + { + id: '2', + type: 'custom', + label: 'Node 2', + position: { x: 300, y: 300 }, + }, + ], + nodeTypes: { + custom: markRaw(CustomNode), + }, + autoConnect: true, + }) + }) + + it('renders custom node', () => { + cy.get('.vue-flow__node-custom').should('have.length', 1) + }) +})