@@ -7,7 +7,15 @@ import {
7
7
TransactionApproval ,
8
8
TransactionModalType ,
9
9
} from './TransactionApproval' ;
10
-
10
+ import { useConfirmationRedesignEnabled } from '../../Views/confirmations/hooks/useConfirmationRedesignEnabled' ;
11
+ import renderWithProvider from '../../../util/test/renderWithProvider' ;
12
+
13
+ jest . mock (
14
+ '../../Views/confirmations/hooks/useConfirmationRedesignEnabled' ,
15
+ ( ) => ( {
16
+ useConfirmationRedesignEnabled : jest . fn ( ) ,
17
+ } ) ,
18
+ ) ;
11
19
jest . mock ( '../../Views/confirmations/hooks/useApprovalRequest' ) ;
12
20
13
21
jest . mock ( '../../UI/QRHardware/withQRHardwareAwareness' , ( ) =>
@@ -30,6 +38,13 @@ const mockApprovalRequest = (approvalRequest?: ApprovalRequest<any>) => {
30
38
describe ( 'TransactionApproval' , ( ) => {
31
39
beforeEach ( ( ) => {
32
40
jest . resetAllMocks ( ) ;
41
+ (
42
+ useConfirmationRedesignEnabled as jest . MockedFn <
43
+ typeof useConfirmationRedesignEnabled
44
+ >
45
+ ) . mockReturnValue ( {
46
+ isRedesignedEnabled : false ,
47
+ } ) ;
33
48
} ) ;
34
49
35
50
it ( 'renders approval component if transaction type is dapp' , ( ) => {
@@ -79,9 +94,9 @@ describe('TransactionApproval', () => {
79
94
it ( 'returns null if no approval request' , ( ) => {
80
95
mockApprovalRequest ( undefined ) ;
81
96
82
- const wrapper = shallow ( < TransactionApproval /> ) ;
97
+ const { toJSON } = renderWithProvider ( < TransactionApproval /> , { } ) ;
83
98
84
- expect ( wrapper ) . toMatchSnapshot ( ) ;
99
+ expect ( toJSON ( ) ) . toMatchInlineSnapshot ( `null` ) ;
85
100
} ) ;
86
101
87
102
it ( 'returns null if incorrect approval request type' , ( ) => {
@@ -91,9 +106,9 @@ describe('TransactionApproval', () => {
91
106
// eslint-disable-next-line @typescript-eslint/no-explicit-any
92
107
} as any ) ;
93
108
94
- const wrapper = shallow ( < TransactionApproval /> ) ;
109
+ const { toJSON } = renderWithProvider ( < TransactionApproval /> , { } ) ;
95
110
96
- expect ( wrapper ) . toMatchSnapshot ( ) ;
111
+ expect ( toJSON ( ) ) . toMatchInlineSnapshot ( `null` ) ;
97
112
} ) ;
98
113
99
114
it ( 'returns null if incorrect transaction type' , ( ) => {
@@ -103,8 +118,34 @@ describe('TransactionApproval', () => {
103
118
// eslint-disable-next-line @typescript-eslint/no-explicit-any
104
119
} as any ) ;
105
120
106
- const wrapper = shallow ( < TransactionApproval transactionType = "invalid" /> ) ;
121
+ const { toJSON } = renderWithProvider (
122
+ < TransactionApproval transactionType = "invalid" /> ,
123
+ { } ,
124
+ ) ;
107
125
108
- expect ( wrapper ) . toMatchSnapshot ( ) ;
126
+ expect ( toJSON ( ) ) . toMatchInlineSnapshot ( `null` ) ;
127
+ } ) ;
128
+
129
+ it ( 'returns null if redesign is enabled' , ( ) => {
130
+ mockApprovalRequest ( {
131
+ type : ApprovalTypes . TRANSACTION ,
132
+ // TODO: Replace "any" with type
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ } as any ) ;
135
+
136
+ (
137
+ useConfirmationRedesignEnabled as jest . MockedFn <
138
+ typeof useConfirmationRedesignEnabled
139
+ >
140
+ ) . mockReturnValue ( {
141
+ isRedesignedEnabled : true ,
142
+ } ) ;
143
+
144
+ const { toJSON } = renderWithProvider (
145
+ < TransactionApproval transactionType = { TransactionModalType . Dapp } /> ,
146
+ { } ,
147
+ ) ;
148
+
149
+ expect ( toJSON ( ) ) . toMatchInlineSnapshot ( `null` ) ;
109
150
} ) ;
110
151
} ) ;
0 commit comments