| 9 | * @returns {Object} Mock Range object |
| 10 | */ |
| 11 | export function createMockRange(overrides = {}) { |
| 12 | const container = overrides.commonAncestorContainer || document.createElement('div'); |
| 13 | return { |
| 14 | commonAncestorContainer: container, |
| 15 | extractContents: jest.fn(() => document.createDocumentFragment()), |
| 16 | insertNode: jest.fn(), |
| 17 | selectNodeContents: jest.fn(), |
| 18 | getBoundingClientRect: jest.fn(() => ({ |
| 19 | width: 300, |
| 20 | height: 100, |
| 21 | top: 0, |
| 22 | left: 0, |
| 23 | right: 300, |
| 24 | bottom: 100 |
| 25 | })), |
| 26 | toString: jest.fn(() => ''), |
| 27 | ...overrides |
| 28 | }; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Creates a mock Selection object |