File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,29 @@ describe("Mouse class", () => {
142142 expect ( result ) . toBe ( SUT ) ;
143143 } ) ;
144144
145+ it ( "should convert single point inputs to an array" , async ( ) => {
146+ // GIVEN
147+ const SUT = new MouseClass ( providerRegistryMock ) ;
148+ const testPoint = new Point ( 0 , 0 ) ;
149+
150+ const setPositionMock = jest . fn ( ) ;
151+ providerRegistryMock . getMouse = jest . fn ( ( ) =>
152+ mockPartial < MouseProviderInterface > ( {
153+ setMouseDelay : jest . fn ( ) ,
154+ setMousePosition : setPositionMock ,
155+ } )
156+ ) ;
157+ providerRegistryMock . getLogProvider = ( ) => new NoopLogProvider ( ) ;
158+
159+ // WHEN
160+ const result = await SUT . move ( testPoint as unknown as Array < Point > ) ;
161+
162+ // THEN
163+ expect ( setPositionMock ) . toBeCalledTimes ( 1 ) ;
164+ expect ( setPositionMock ) . toBeCalledWith ( testPoint ) ;
165+ expect ( result ) . toBe ( SUT ) ;
166+ } ) ;
167+
145168 it ( "should press and hold left mouse button, move and release left mouse button on drag" , async ( ) => {
146169 // GIVEN
147170 const SUT = new MouseClass ( providerRegistryMock ) ;
Original file line number Diff line number Diff line change @@ -90,7 +90,10 @@ export class MouseClass {
9090 ) : Promise < MouseClass > {
9191 return new Promise < MouseClass > ( async ( resolve , reject ) => {
9292 try {
93- const pathSteps = await path ;
93+ let pathSteps = await path ;
94+ if ( ! Array . isArray ( pathSteps ) ) {
95+ pathSteps = [ pathSteps ] ;
96+ }
9497 this . providerRegistry
9598 . getLogProvider ( )
9699 . info (
You can’t perform that action at this time.
0 commit comments