(tagName, options = {})
| 79 | } |
| 80 | |
| 81 | export function getMockElement(tagName, options = {}) { |
| 82 | const elem = document.createElement(tagName); |
| 83 | let { |
| 84 | width = 0, |
| 85 | height = 0, |
| 86 | top = 0, |
| 87 | bottom = 0, |
| 88 | left = 0, |
| 89 | right = 0, |
| 90 | } = options; |
| 91 | elem.getBoundingClientRect = () => { |
| 92 | return { |
| 93 | width, |
| 94 | height, |
| 95 | top, |
| 96 | bottom, |
| 97 | left, |
| 98 | right, |
| 99 | }; |
| 100 | }; |
| 101 | elem.setWidth = (newWidth) => { |
| 102 | width = newWidth; |
| 103 | }; |
| 104 | elem.setHeight = (newHeight) => { |
| 105 | height = newHeight; |
| 106 | }; |
| 107 | // console.log(elem.ownerDocument); |
| 108 | // elem.ownerDocument = document; |
| 109 | // elem.ownerDocument.defaultView = window; |
| 110 | return elem; |
| 111 | } |
no test coverage detected
searching dependent graphs…