@@ -38,22 +38,21 @@ describe("Screen.", () => {
38
38
// GIVEN
39
39
const matchResult = new MatchResult ( 0.99 , searchRegion ) ;
40
40
const SUT = new ScreenClass ( providerRegistryMock ) ;
41
- const imagePath = "test/path/to/image.png" ;
41
+ const needle = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 ) ;
42
42
43
43
const findMatchMock = jest . fn ( ( ) => Promise . resolve ( matchResult ) ) ;
44
44
providerRegistryMock . getImageFinder = jest . fn ( ( ) => mockPartial < ImageFinderInterface > ( {
45
45
findMatch : findMatchMock
46
46
} ) ) ;
47
47
48
48
// WHEN
49
- const resultRegion = SUT . find ( imagePath ) ;
49
+ const resultRegion = SUT . find ( needle ) ;
50
50
51
51
// THEN
52
52
await expect ( resultRegion ) . resolves . toEqual ( matchResult . location ) ;
53
53
const matchRequest = new MatchRequest (
54
54
expect . any ( Image ) ,
55
- join ( cwd ( ) , imagePath ) ,
56
- searchRegion ,
55
+ needle ,
57
56
SUT . config . confidence ,
58
57
true ) ;
59
58
expect ( findMatchMock ) . toHaveBeenCalledWith ( matchRequest ) ;
@@ -69,11 +68,11 @@ describe("Screen.", () => {
69
68
70
69
const SUT = new ScreenClass ( providerRegistryMock ) ;
71
70
const testCallback = jest . fn ( ( ) => Promise . resolve ( ) ) ;
72
- const imagePath = "test/path/to/image.png" ;
73
- SUT . on ( imagePath , testCallback ) ;
71
+ const needle = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 ) ;
72
+ SUT . on ( needle , testCallback ) ;
74
73
75
74
// WHEN
76
- await SUT . find ( imagePath ) ;
75
+ await SUT . find ( needle ) ;
77
76
78
77
// THEN
79
78
expect ( testCallback ) . toBeCalledTimes ( 1 ) ;
@@ -91,12 +90,12 @@ describe("Screen.", () => {
91
90
const SUT = new ScreenClass ( providerRegistryMock ) ;
92
91
const testCallback = jest . fn ( ( ) => Promise . resolve ( ) ) ;
93
92
const secondCallback = jest . fn ( ( ) => Promise . resolve ( ) ) ;
94
- const imagePath = "test/path/to/image.png" ;
95
- SUT . on ( imagePath , testCallback ) ;
96
- SUT . on ( imagePath , secondCallback ) ;
93
+ const needle = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 ) ;
94
+ SUT . on ( needle , testCallback ) ;
95
+ SUT . on ( needle , secondCallback ) ;
97
96
98
97
// WHEN
99
- await SUT . find ( imagePath ) ;
98
+ await SUT . find ( needle ) ;
100
99
101
100
// THEN
102
101
for ( const callback of [ testCallback , secondCallback ] ) {
@@ -160,18 +159,17 @@ describe("Screen.", () => {
160
159
161
160
const SUT = new ScreenClass ( providerRegistryMock ) ;
162
161
163
- const imagePath = "test/path/to/image.png" ;
162
+ const needle = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 ) ;
164
163
const parameters = new LocationParameters ( undefined , minMatch ) ;
165
164
166
165
// WHEN
167
- const resultRegion = SUT . find ( imagePath , parameters ) ;
166
+ const resultRegion = SUT . find ( needle , parameters ) ;
168
167
169
168
// THEN
170
169
await expect ( resultRegion ) . resolves . toEqual ( matchResult . location ) ;
171
170
const matchRequest = new MatchRequest (
172
171
expect . any ( Image ) ,
173
- join ( cwd ( ) , imagePath ) ,
174
- searchRegion ,
172
+ needle ,
175
173
minMatch ,
176
174
true ) ;
177
175
expect ( findMatchMock ) . toHaveBeenCalledWith ( matchRequest ) ;
@@ -189,17 +187,16 @@ describe("Screen.", () => {
189
187
190
188
const SUT = new ScreenClass ( providerRegistryMock ) ;
191
189
192
- const imagePath = "test/path/to/image.png" ;
190
+ const needle = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 ) ;
193
191
const parameters = new LocationParameters ( customSearchRegion ) ;
194
192
const expectedMatchRequest = new MatchRequest (
195
193
expect . any ( Image ) ,
196
- join ( cwd ( ) , imagePath ) ,
197
- customSearchRegion ,
194
+ needle ,
198
195
SUT . config . confidence ,
199
196
true ) ;
200
197
201
198
// WHEN
202
- await SUT . find ( imagePath , parameters ) ;
199
+ await SUT . find ( needle , parameters ) ;
203
200
204
201
// THEN
205
202
expect ( findMatchMock ) . toHaveBeenCalledWith ( expectedMatchRequest ) ;
@@ -214,17 +211,17 @@ describe("Screen.", () => {
214
211
} ) ) ;
215
212
216
213
const SUT = new ScreenClass ( providerRegistryMock ) ;
217
- const imagePath = "test/path/to/image.png" ;
214
+ const needle = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 ) ;
215
+
218
216
const parameters = new LocationParameters ( searchRegion , undefined , false ) ;
219
217
const expectedMatchRequest = new MatchRequest (
220
218
expect . any ( Image ) ,
221
- join ( cwd ( ) , imagePath ) ,
222
- searchRegion ,
219
+ needle ,
223
220
SUT . config . confidence ,
224
221
false ) ;
225
222
226
223
// WHEN
227
- await SUT . find ( imagePath , parameters ) ;
224
+ await SUT . find ( needle , parameters ) ;
228
225
229
226
// THEN
230
227
expect ( findMatchMock ) . toHaveBeenCalledWith ( expectedMatchRequest ) ;
@@ -241,17 +238,16 @@ describe("Screen.", () => {
241
238
} ) ) ;
242
239
243
240
const SUT = new ScreenClass ( providerRegistryMock ) ;
244
- const imagePath = "test/path/to/image.png" ;
241
+ const needle = new Image ( 100 , 100 , Buffer . from ( [ ] ) , 3 ) ;
245
242
const parameters = new LocationParameters ( customSearchRegion , minMatch ) ;
246
243
const expectedMatchRequest = new MatchRequest (
247
244
expect . any ( Image ) ,
248
- join ( cwd ( ) , imagePath ) ,
249
- customSearchRegion ,
245
+ needle ,
250
246
minMatch ,
251
247
true ) ;
252
248
253
249
// WHEN
254
- await SUT . find ( imagePath , parameters ) ;
250
+ await SUT . find ( needle , parameters ) ;
255
251
256
252
// THEN
257
253
expect ( findMatchMock ) . toHaveBeenCalledWith ( expectedMatchRequest ) ;
0 commit comments