compat-contract.spec.ts 1.08 KB
import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import type { FlowEditorRef } from '@flow-editor'
import FlowEditor from '../../packages/flow-editor/src/components/FlowEditor.vue'

describe('FlowEditor 兼容层', () => {
  it('应通过 onRef 暴露最小实例契约', () => {
    let editorInstance: FlowEditorRef | null = null

    mount(FlowEditor, {
      props: {
        enableEngine: false,
        onRef: (instance: FlowEditorRef) => {
          editorInstance = instance
        },
      },
    })

    expect(editorInstance).not.toBeNull()
    expect(typeof editorInstance?.commander.delete).toBe('function')
    expect(typeof editorInstance?.commander.undo).toBe('function')
    expect(typeof editorInstance?.commander.redo).toBe('function')
    expect(typeof editorInstance?.openModel).toBe('function')
    expect(typeof editorInstance?.closeModel).toBe('function')
    expect(typeof editorInstance?.addNode).toBe('function')
    expect(typeof editorInstance?.updateModel).toBe('function')
    expect(typeof editorInstance?.read).toBe('function')
  })
})