You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test-utils.ts 786B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Data } from 'types'
  2. import { getSelectedIds } from 'utils/utils'
  3. interface PointerOptions {
  4. id?: string
  5. x?: number
  6. y?: number
  7. shiftKey?: boolean
  8. altKey?: boolean
  9. ctrlKey?: boolean
  10. }
  11. export function point(
  12. options: PointerOptions = {} as PointerOptions
  13. ): PointerEvent {
  14. const {
  15. id = '1',
  16. x = 0,
  17. y = 0,
  18. shiftKey = false,
  19. altKey = false,
  20. ctrlKey = false,
  21. } = options
  22. return {
  23. shiftKey,
  24. altKey,
  25. ctrlKey,
  26. pointerId: id,
  27. clientX: x,
  28. clientY: y,
  29. } as any
  30. }
  31. export function idsAreSelected(
  32. data: Data,
  33. ids: string[],
  34. strict = true
  35. ): boolean {
  36. const selectedIds = getSelectedIds(data)
  37. return (
  38. (strict ? selectedIds.size === ids.length : true) &&
  39. ids.every((id) => selectedIds.has(id))
  40. )
  41. }