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 909B

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