@@ -2,18 +2,24 @@ import {AssertClass} from "./assert.class";
22import { Region } from "./region.class" ;
33import { ScreenClass } from "./screen.class" ;
44import providerRegistry from "./provider/provider-registry.class" ;
5+ import { Image } from "../index" ;
6+ import { mockPartial } from "sneer" ;
57
68jest . mock ( 'jimp' , ( ) => {
79} ) ;
810jest . mock ( "./screen.class" ) ;
911
12+ const needleId = "needleId" ;
13+
1014describe ( "Assert" , ( ) => {
1115 it ( "isVisible should not throw if a match is found." , async ( ) => {
1216 // GIVEN
1317 ScreenClass . prototype . find = jest . fn ( ( ) => Promise . resolve ( new Region ( 0 , 0 , 100 , 100 ) ) ) ;
1418 const screenMock = new ScreenClass ( providerRegistry ) ;
1519 const SUT = new AssertClass ( screenMock ) ;
16- const needle = "foo" ;
20+ const needle = mockPartial < Image > ( {
21+ id : needleId
22+ } ) ;
1723
1824 // WHEN
1925
@@ -26,12 +32,14 @@ describe("Assert", () => {
2632 ScreenClass . prototype . find = jest . fn ( ( ) => Promise . reject ( "foo" ) ) ;
2733 const screenMock = new ScreenClass ( providerRegistry ) ;
2834 const SUT = new AssertClass ( screenMock ) ;
29- const needle = "foo" ;
35+ const needle = mockPartial < Image > ( {
36+ id : needleId
37+ } ) ;
3038
3139 // WHEN
3240
3341 // 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` ) ;
3543 } ) ;
3644
3745 it ( "isVisible should throw if a match is found." , async ( ) => {
@@ -40,14 +48,16 @@ describe("Assert", () => {
4048 const screenMock = new ScreenClass ( providerRegistry ) ;
4149 const SUT = new AssertClass ( screenMock ) ;
4250 const searchRegion = new Region ( 10 , 10 , 10 , 10 ) ;
43- const needle = "foo" ;
51+ const needle = mockPartial < Image > ( {
52+ id : needleId
53+ } ) ;
4454
4555 // WHEN
4656
4757 // THEN
4858 await expect ( SUT
4959 . 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 ( ) } `
5161 ) ;
5262 } ) ;
5363
@@ -56,20 +66,24 @@ describe("Assert", () => {
5666 ScreenClass . prototype . find = jest . fn ( ( ) => Promise . resolve ( new Region ( 0 , 0 , 100 , 100 ) ) ) ;
5767 const screenMock = new ScreenClass ( providerRegistry ) ;
5868 const SUT = new AssertClass ( screenMock ) ;
59- const needle = "foo" ;
69+ const needle = mockPartial < Image > ( {
70+ id : needleId
71+ } ) ;
6072
6173 // WHEN
6274
6375 // THEN
64- await expect ( SUT . notVisible ( needle ) ) . rejects . toThrowError ( `'${ needle } ' is visible` ) ;
76+ await expect ( SUT . notVisible ( needle ) ) . rejects . toThrowError ( `'${ needle . id } ' is visible` ) ;
6577 } ) ;
6678
6779 it ( "isVisible should throw if a match is found." , async ( ) => {
6880 // GIVEN
6981 ScreenClass . prototype . find = jest . fn ( ( ) => Promise . reject ( "foo" ) ) ;
7082 const screenMock = new ScreenClass ( providerRegistry ) ;
7183 const SUT = new AssertClass ( screenMock ) ;
72- const needle = "foo" ;
84+ const needle = mockPartial < Image > ( {
85+ id : needleId
86+ } ) ;
7387
7488 // WHEN
7589
0 commit comments