@@ -4,30 +4,20 @@ import SimpleWebview from './';
44import { useNavigation } from '@react-navigation/native' ;
55import Share from 'react-native-share' ;
66import Logger from '../../../util/Logger' ;
7- import getHeaderCompactStandardNavbarOptions from '../../../component-library/components-temp/HeaderCompactStandard/getHeaderCompactStandardNavbarOptions' ;
8- import Device from '../../../util/device' ;
7+ import HeaderCompactStandard from '../../../component-library/components-temp/HeaderCompactStandard' ;
98
109jest . mock (
11- '../../../component-library/components-temp/HeaderCompactStandard/getHeaderCompactStandardNavbarOptions ' ,
10+ '../../../component-library/components-temp/HeaderCompactStandard' ,
1211 ( ) => ( {
1312 __esModule : true ,
14- default : jest . fn ( ( ) => ( {
15- header : ( ) => null ,
16- } ) ) ,
13+ default : jest . fn ( ( ) => null ) ,
1714 } ) ,
1815) ;
1916
20- jest . mock ( '../../../util/device' , ( ) => ( {
21- __esModule : true ,
22- default : {
23- isAndroid : jest . fn ( ( ) => false ) ,
24- } ,
25- } ) ) ;
26-
27- const mockSetOptions = jest . fn ( ) ;
17+ const mockGoBack = jest . fn ( ) ;
2818const mockNavigation = {
29- goBack : jest . fn ( ) ,
30- setOptions : mockSetOptions ,
19+ goBack : mockGoBack ,
20+ setOptions : jest . fn ( ) ,
3121} ;
3222
3323jest . mock ( '@react-navigation/native' , ( ) => ( {
@@ -48,64 +38,38 @@ describe('SimpleWebview', () => {
4838 ( Share . open as jest . Mock ) . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
4939 } ) ;
5040
51- it ( 'renders correctly ' , ( ) => {
41+ it ( 'renders the HeaderCompactStandard with safe area top inset ' , ( ) => {
5242 render ( < SimpleWebview /> ) ;
5343
54- expect ( getHeaderCompactStandardNavbarOptions ) . toHaveBeenCalled ( ) ;
55- } ) ;
56-
57- it ( 'sets header options from HeaderCompactStandard and Device.isAndroid() for includesTopInset' , ( ) => {
58- render ( < SimpleWebview /> ) ;
59-
60- expect ( getHeaderCompactStandardNavbarOptions ) . toHaveBeenCalledWith (
44+ expect ( HeaderCompactStandard ) . toHaveBeenCalledWith (
6145 expect . objectContaining ( {
6246 title : '' ,
63- includesTopInset : false ,
64- twClassName : 'bg-default rounded-t-2xl' ,
47+ includesTopInset : true ,
6548 onBack : expect . any ( Function ) ,
6649 endButtonIconProps : expect . arrayContaining ( [
6750 expect . objectContaining ( { onPress : expect . any ( Function ) } ) ,
6851 ] ) ,
6952 } ) ,
70- ) ;
71- expect ( mockSetOptions ) . toHaveBeenCalledWith (
72- expect . objectContaining ( {
73- header : expect . any ( Function ) ,
74- } ) ,
75- ) ;
76- expect ( mockSetOptions . mock . calls [ 0 ] [ 0 ] ) . not . toHaveProperty ( 'headerStyle' ) ;
77- } ) ;
78-
79- it ( 'passes includesTopInset true when Device.isAndroid() is true' , ( ) => {
80- jest . mocked ( Device . isAndroid ) . mockReturnValueOnce ( true ) ;
81- render ( < SimpleWebview /> ) ;
82-
83- expect ( getHeaderCompactStandardNavbarOptions ) . toHaveBeenCalledWith (
84- expect . objectContaining ( {
85- includesTopInset : true ,
86- } ) ,
53+ expect . anything ( ) ,
8754 ) ;
8855 } ) ;
8956
9057 it ( 'calls navigation.goBack when header onBack is invoked' , ( ) => {
9158 render ( < SimpleWebview /> ) ;
9259
93- const { onBack } = ( getHeaderCompactStandardNavbarOptions as jest . Mock ) . mock
60+ const headerProps = ( HeaderCompactStandard as unknown as jest . Mock ) . mock
9461 . calls [ 0 ] [ 0 ] as { onBack : ( ) => void } ;
95- onBack ( ) ;
62+ headerProps . onBack ( ) ;
9663
97- expect ( mockNavigation . goBack ) . toHaveBeenCalled ( ) ;
64+ expect ( mockGoBack ) . toHaveBeenCalled ( ) ;
9865 } ) ;
9966
10067 it ( 'calls Share.open when share button onPress is invoked' , ( ) => {
10168 render ( < SimpleWebview /> ) ;
10269
103- const { endButtonIconProps } = (
104- getHeaderCompactStandardNavbarOptions as jest . Mock
105- ) . mock . calls [ 0 ] [ 0 ] as {
106- endButtonIconProps : { onPress : ( ) => void } [ ] ;
107- } ;
108- endButtonIconProps [ 0 ] . onPress ( ) ;
70+ const headerProps = ( HeaderCompactStandard as unknown as jest . Mock ) . mock
71+ . calls [ 0 ] [ 0 ] as { endButtonIconProps : { onPress : ( ) => void } [ ] } ;
72+ headerProps . endButtonIconProps [ 0 ] . onPress ( ) ;
10973
11074 expect ( Share . open ) . toHaveBeenCalledWith ( { url : 'https://etherscan.io' } ) ;
11175 } ) ;
@@ -116,12 +80,9 @@ describe('SimpleWebview', () => {
11680
11781 render ( < SimpleWebview /> ) ;
11882
119- const { endButtonIconProps } = (
120- getHeaderCompactStandardNavbarOptions as jest . Mock
121- ) . mock . calls [ 0 ] [ 0 ] as {
122- endButtonIconProps : { onPress : ( ) => void } [ ] ;
123- } ;
124- endButtonIconProps [ 0 ] . onPress ( ) ;
83+ const headerProps = ( HeaderCompactStandard as unknown as jest . Mock ) . mock
84+ . calls [ 0 ] [ 0 ] as { endButtonIconProps : { onPress : ( ) => void } [ ] } ;
85+ headerProps . endButtonIconProps [ 0 ] . onPress ( ) ;
12586
12687 await waitFor ( ( ) => {
12788 expect ( log ) . toHaveBeenCalledWith (
0 commit comments