@@ -9,7 +9,7 @@ describe('Button', () => {
99 const title = 'Press Me' ;
1010 const color = '#f8a978' ;
1111 const x = 40 ;
12- const y = 20 ;
12+ const y = 300 ;
1313 const width = x + y ;
1414 const height = ButtonDefaults . containerStyle . height ;
1515 const props = { title, color} ;
@@ -25,7 +25,11 @@ describe('Button', () => {
2525 lineTo : jest . fn ( ) ,
2626 quadraticCurveTo : jest . fn ( ) ,
2727 font : 'Helvetica' ,
28- measureText : jest . fn ( ) ,
28+ measureText : jest . fn ( ( ) => {
29+ return {
30+ width : 100 ,
31+ } ;
32+ } ) ,
2933 canvas : {
3034 addEventListener : jest . fn ( ) ,
3135 } ,
@@ -54,10 +58,10 @@ describe('Button', () => {
5458 expect ( lineTo . mock . calls . length ) . toEqual ( 4 ) ;
5559 expect ( fill . mock . calls . length ) . toBe ( 1 ) ;
5660 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` ) ;
5963 expect ( quadraticCurveTo . mock . calls . length ) . toEqual ( 4 ) ;
60- expect ( fillStyle ) . toBe ( color ) ;
64+ expect ( fillStyle ) . toEqual ( 'white' ) ;
6165 expect ( Button ) . toMatchSnapshot ( ) ;
6266 } ) ;
6367 } ) ;
0 commit comments