@@ -2,18 +2,24 @@ import {AssertClass} from "./assert.class";
2
2
import { Region } from "./region.class" ;
3
3
import { ScreenClass } from "./screen.class" ;
4
4
import providerRegistry from "./provider/provider-registry.class" ;
5
+ import { Image } from "../index" ;
6
+ import { mockPartial } from "sneer" ;
5
7
6
8
jest . mock ( 'jimp' , ( ) => {
7
9
} ) ;
8
10
jest . mock ( "./screen.class" ) ;
9
11
12
+ const needleId = "needleId" ;
13
+
10
14
describe ( "Assert" , ( ) => {
11
15
it ( "isVisible should not throw if a match is found." , async ( ) => {
12
16
// GIVEN
13
17
ScreenClass . prototype . find = jest . fn ( ( ) => Promise . resolve ( new Region ( 0 , 0 , 100 , 100 ) ) ) ;
14
18
const screenMock = new ScreenClass ( providerRegistry ) ;
15
19
const SUT = new AssertClass ( screenMock ) ;
16
- const needle = "foo" ;
20
+ const needle = mockPartial < Image > ( {
21
+ id : needleId
22
+ } ) ;
17
23
18
24
// WHEN
19
25
@@ -26,12 +32,14 @@ describe("Assert", () => {
26
32
ScreenClass . prototype . find = jest . fn ( ( ) => Promise . reject ( "foo" ) ) ;
27
33
const screenMock = new ScreenClass ( providerRegistry ) ;
28
34
const SUT = new AssertClass ( screenMock ) ;
29
- const needle = "foo" ;
35
+ const needle = mockPartial < Image > ( {
36
+ id : needleId
37
+ } ) ;
30
38
31
39
// WHEN
32
40
33
41
// THEN
34
- await expect ( SUT . isVisible ( needle ) ) . rejects . toThrowError ( `Element '${ needle } ' not found` ) ;
42
+ await expect ( SUT . isVisible ( needle ) ) . rejects . toThrowError ( `Element '${ needle . id } ' not found` ) ;
35
43
} ) ;
36
44
37
45
it ( "isVisible should throw if a match is found." , async ( ) => {
@@ -40,14 +48,16 @@ describe("Assert", () => {
40
48
const screenMock = new ScreenClass ( providerRegistry ) ;
41
49
const SUT = new AssertClass ( screenMock ) ;
42
50
const searchRegion = new Region ( 10 , 10 , 10 , 10 ) ;
43
- const needle = "foo" ;
51
+ const needle = mockPartial < Image > ( {
52
+ id : needleId
53
+ } ) ;
44
54
45
55
// WHEN
46
56
47
57
// THEN
48
58
await expect ( SUT
49
59
. isVisible ( needle , searchRegion ) )
50
- . rejects . toThrowError ( `Element '${ needle } ' not found in region ${ searchRegion . toString ( ) } `
60
+ . rejects . toThrowError ( `Element '${ needle . id } ' not found in region ${ searchRegion . toString ( ) } `
51
61
) ;
52
62
} ) ;
53
63
@@ -56,20 +66,24 @@ describe("Assert", () => {
56
66
ScreenClass . prototype . find = jest . fn ( ( ) => Promise . resolve ( new Region ( 0 , 0 , 100 , 100 ) ) ) ;
57
67
const screenMock = new ScreenClass ( providerRegistry ) ;
58
68
const SUT = new AssertClass ( screenMock ) ;
59
- const needle = "foo" ;
69
+ const needle = mockPartial < Image > ( {
70
+ id : needleId
71
+ } ) ;
60
72
61
73
// WHEN
62
74
63
75
// THEN
64
- await expect ( SUT . notVisible ( needle ) ) . rejects . toThrowError ( `'${ needle } ' is visible` ) ;
76
+ await expect ( SUT . notVisible ( needle ) ) . rejects . toThrowError ( `'${ needle . id } ' is visible` ) ;
65
77
} ) ;
66
78
67
79
it ( "isVisible should throw if a match is found." , async ( ) => {
68
80
// GIVEN
69
81
ScreenClass . prototype . find = jest . fn ( ( ) => Promise . reject ( "foo" ) ) ;
70
82
const screenMock = new ScreenClass ( providerRegistry ) ;
71
83
const SUT = new AssertClass ( screenMock ) ;
72
- const needle = "foo" ;
84
+ const needle = mockPartial < Image > ( {
85
+ id : needleId
86
+ } ) ;
73
87
74
88
// WHEN
75
89
0 commit comments