Skip to content

mockDragData

Jason Godesky edited this page Jul 17, 2026 · 3 revisions

mockDragData mocks Foundry’s TextEditor.getDragEventData utility method so that you can test code that uses it.

Parameters

[documents?: Record<string, foundry.abstract.Document>](data: { type?: string; uuid?: string })`

The data that you would like the mock to return.

Examples

import { afterEach, describe, expect, it, vi } from 'vitest'
import { mockDragData } from '@revolutionarygamesco/common-foundryvtt/mocks'

describe('getDroppedDocument', () => {
  afterEach(() => {
    vi.unstubAllGlobals()
  })

  it('gets the UUID', () => {
    const uuid = 'Actor.1111111111111111'
    mockDragData({ uuid })
    const data = foundry.applications.ux.TextEditor.getDragEventData(event) as { uuid?: string }
    expect(data.uuid).toBe(uuid)
  })
})

Clone this wiki locally