@@ -9,8 +9,12 @@ import {
99 DRAG_DELAY ,
1010 drag ,
1111} from 'helper' ;
12+ import { FixMeAny } from 'shared/types' ;
1213
13- import { Draggable } from '../../..' ;
14+ /* eslint-disable @typescript-eslint/ban-ts-comment */
15+ // @ts -ignore
16+ import Draggable from '../../../Draggable' ;
17+ /* eslint-enable @typescript-eslint/ban-ts-comment */
1418import ResizeMirror from '..' ;
1519
1620const sampleMarkup = `
@@ -36,17 +40,17 @@ describe('ResizeMirror', () => {
3640 height : smallerDraggableDimensions . height * 2 ,
3741 } ;
3842
39- let sandbox ;
40- let containers ;
41- let draggable ;
42- let draggables ;
43- let smallerDraggable ;
44- let largerDraggable ;
43+ let sandbox : HTMLDivElement ;
44+ let containers : HTMLElement [ ] ;
45+ let draggable : FixMeAny ;
46+ let draggables : HTMLElement [ ] ;
47+ let smallerDraggable : HTMLElement ;
48+ let largerDraggable : HTMLElement ;
4549
4650 beforeEach ( ( ) => {
4751 sandbox = createSandbox ( sampleMarkup ) ;
48- containers = sandbox . querySelectorAll ( '.Container' ) ;
49- draggables = sandbox . querySelectorAll ( 'li' ) ;
52+ containers = [ ... sandbox . querySelectorAll < HTMLElement > ( '.Container' ) ] ;
53+ draggables = [ ... sandbox . querySelectorAll < HTMLElement > ( 'li' ) ] ;
5054
5155 smallerDraggable = draggables [ 0 ] ;
5256 largerDraggable = draggables [ 1 ] ;
@@ -71,7 +75,7 @@ describe('ResizeMirror', () => {
7175 waitForDragDelay ( ) ;
7276 await waitForPromisesToResolve ( ) ;
7377
74- const mirror = document . querySelector ( '.draggable-mirror' ) ;
78+ const mirror = document . querySelector < HTMLElement > ( '.draggable-mirror' ) ! ;
7579
7680 expect ( mirror . style ) . toMatchObject ( {
7781 width : `${ smallerDraggableDimensions . width } px` ,
@@ -104,7 +108,7 @@ describe('ResizeMirror', () => {
104108 waitForDragDelay ( ) ;
105109 await waitForPromisesToResolve ( ) ;
106110
107- const mirror = document . querySelector ( '.draggable-mirror' ) ;
111+ const mirror = document . querySelector < HTMLElement > ( '.draggable-mirror' ) ! ;
108112
109113 moveMouse ( largerDraggable ) ;
110114 waitForRequestAnimationFrame ( ) ;
@@ -119,7 +123,7 @@ describe('ResizeMirror', () => {
119123 waitForDragDelay ( ) ;
120124 await waitForPromisesToResolve ( ) ;
121125
122- const mirror = document . querySelector ( '.draggable-mirror' ) ;
126+ const mirror = document . querySelector < HTMLElement > ( '.draggable-mirror' ) ! ;
123127
124128 const mockedAppendChild = withMockedAppendChild ( ( ) => {
125129 moveMouse ( smallerDraggable ) ;
@@ -145,19 +149,28 @@ describe('ResizeMirror', () => {
145149 } ) ;
146150} ) ;
147151
148- function mockDimensions ( element , { width = 0 , height = 0 } ) {
152+ function mockDimensions ( element : HTMLElement , { width = 0 , height = 0 } ) {
149153 Object . assign ( element . style , {
150154 width : `${ width } px` ,
151155 height : `${ height } px` ,
152156 } ) ;
153157
154- element . getBoundingClientRect = ( ) => ( {
158+ const properties = {
155159 width,
156160 height,
157161 top : 0 ,
158162 left : 0 ,
159163 right : width ,
160164 bottom : height ,
165+ x : 0 ,
166+ y : 0 ,
167+ } ;
168+
169+ element . getBoundingClientRect = ( ) => ( {
170+ ...properties ,
171+ toJSON ( ) {
172+ return { ...properties } ;
173+ } ,
161174 } ) ;
162175
163176 return element ;
@@ -168,13 +181,16 @@ function waitForNextRequestAnimationFrame() {
168181 waitForRequestAnimationFrame ( ) ;
169182}
170183
171- function withMockedAppendChild ( callback ) {
184+ function withMockedAppendChild ( callback : ( ) => void ) {
172185 const mock = jest . fn ( ) ;
173186 const appendChild = Node . prototype . appendChild ;
174- Node . prototype . appendChild = function ( ...args ) {
187+ /* eslint-disable @typescript-eslint/ban-ts-comment */
188+ // @ts -ignore
189+ Node . prototype . appendChild = function ( this : Node , ...args ) {
175190 mock ( ...args ) ;
176191 return appendChild . call ( this , ...args ) ;
177192 } ;
193+ /* eslint-enable @typescript-eslint/ban-ts-comment */
178194 callback ( ) ;
179195 Node . prototype . appendChild = appendChild ;
180196 return mock ;
0 commit comments