@@ -9,7 +9,7 @@ describe('Button', () => {
9
9
const title = 'Press Me' ;
10
10
const color = '#f8a978' ;
11
11
const x = 40 ;
12
- const y = 20 ;
12
+ const y = 300 ;
13
13
const width = x + y ;
14
14
const height = ButtonDefaults . containerStyle . height ;
15
15
const props = { title, color} ;
@@ -25,7 +25,11 @@ describe('Button', () => {
25
25
lineTo : jest . fn ( ) ,
26
26
quadraticCurveTo : jest . fn ( ) ,
27
27
font : 'Helvetica' ,
28
- measureText : jest . fn ( ) ,
28
+ measureText : jest . fn ( ( ) => {
29
+ return {
30
+ width : 100 ,
31
+ } ;
32
+ } ) ,
29
33
canvas : {
30
34
addEventListener : jest . fn ( ) ,
31
35
} ,
@@ -54,10 +58,10 @@ describe('Button', () => {
54
58
expect ( lineTo . mock . calls . length ) . toEqual ( 4 ) ;
55
59
expect ( fill . mock . calls . length ) . toBe ( 1 ) ;
56
60
expect ( fillText . mock . calls . length ) . toBe ( 1 ) ;
57
- expect ( fillText ) . toBeCalledWith ( title , x + width / 2 , y + height / 2 ) ;
58
- expect ( font ) . toEqual ( `${ ButtonDefaults . textStyle . fontSize } Helvetica` ) ;
61
+ expect ( fillText . mock . calls . length ) . toBe ( 1 ) ;
62
+ expect ( font ) . toEqual ( `${ ButtonDefaults . textStyle . fontSize } px Helvetica` ) ;
59
63
expect ( quadraticCurveTo . mock . calls . length ) . toEqual ( 4 ) ;
60
- expect ( fillStyle ) . toBe ( color ) ;
64
+ expect ( fillStyle ) . toEqual ( 'white' ) ;
61
65
expect ( Button ) . toMatchSnapshot ( ) ;
62
66
} ) ;
63
67
} ) ;
0 commit comments