@@ -137,52 +137,54 @@ describe("Screen.", () => {
137137 } ) ;
138138
139139 it ( "should override default search region with parameter." , async ( ) => {
140+ // GIVEN
140141 const customSearchRegion = new Region ( 10 , 10 , 90 , 90 ) ;
141142 const matchResult = new MatchResult ( 0.99 , searchRegion ) ;
142-
143143 VisionAdapter . prototype . findOnScreenRegion = jest . fn ( ( ) => {
144144 return Promise . resolve ( matchResult ) ;
145145 } ) ;
146-
147146 const visionAdapterMock = new VisionAdapter ( ) ;
148-
149147 const SUT = new Screen ( visionAdapterMock ) ;
150-
151148 const imagePath = "test/path/to/image.png" ;
152149 const parameters = new LocationParameters ( customSearchRegion ) ;
153- await expect ( SUT . find ( imagePath , parameters ) ) . resolves . toEqual ( matchResult . location ) ;
154- const matchRequest = new MatchRequest (
155- expect . any ( Image ) ,
156- join ( cwd ( ) , imagePath ) ,
157- customSearchRegion ,
158- SUT . config . confidence ,
159- true ) ;
160- expect ( visionAdapterMock . findOnScreenRegion ) . toHaveBeenCalledWith ( matchRequest ) ;
150+ const expectedMatchRequest = new MatchRequest (
151+ expect . any ( Image ) ,
152+ join ( cwd ( ) , imagePath ) ,
153+ customSearchRegion ,
154+ SUT . config . confidence ,
155+ true ) ;
156+
157+ // WHEN
158+ await SUT . find ( imagePath , parameters ) ;
159+
160+ // THEN
161+ expect ( visionAdapterMock . findOnScreenRegion ) . toHaveBeenCalledWith ( expectedMatchRequest ) ;
161162 } ) ;
162163
163164 it ( "should override both confidence and search region with parameter." , async ( ) => {
165+ // GIVEN
164166 const minMatch = 0.8 ;
165167 const customSearchRegion = new Region ( 10 , 10 , 90 , 90 ) ;
166168 const matchResult = new MatchResult ( minMatch , searchRegion ) ;
167-
168169 VisionAdapter . prototype . findOnScreenRegion = jest . fn ( ( ) => {
169170 return Promise . resolve ( matchResult ) ;
170171 } ) ;
171-
172172 const visionAdapterMock = new VisionAdapter ( ) ;
173-
174173 const SUT = new Screen ( visionAdapterMock ) ;
175-
176174 const imagePath = "test/path/to/image.png" ;
177175 const parameters = new LocationParameters ( customSearchRegion , minMatch ) ;
178- await expect ( SUT . find ( imagePath , parameters ) ) . resolves . toEqual ( matchResult . location ) ;
179- const matchRequest = new MatchRequest (
180- expect . any ( Image ) ,
181- join ( cwd ( ) , imagePath ) ,
182- customSearchRegion ,
183- minMatch ,
184- true ) ;
185- expect ( visionAdapterMock . findOnScreenRegion ) . toHaveBeenCalledWith ( matchRequest ) ;
176+ const expectedMatchRequest = new MatchRequest (
177+ expect . any ( Image ) ,
178+ join ( cwd ( ) , imagePath ) ,
179+ customSearchRegion ,
180+ minMatch ,
181+ true ) ;
182+
183+ // WHEN
184+ await SUT . find ( imagePath , parameters ) ;
185+
186+ // THEN
187+ expect ( visionAdapterMock . findOnScreenRegion ) . toHaveBeenCalledWith ( expectedMatchRequest ) ;
186188 } ) ;
187189
188190 it ( "should return region to highlight for chaining" , async ( ) => {
0 commit comments