@@ -4,24 +4,19 @@ import { render, fireEvent } from "@testing-library/react";
44import { PayLaterOneTimePaymentButton } from "./PayLaterOneTimePaymentButton" ;
55import { usePayLaterOneTimePaymentSession } from "../hooks/usePayLaterOneTimePaymentSession" ;
66import { usePayPal } from "../hooks/usePayPal" ;
7- import { useEligibleMethods } from "../hooks/useEligibleMethods" ;
87
98jest . mock ( "../hooks/usePayLaterOneTimePaymentSession" , ( ) => ( {
109 usePayLaterOneTimePaymentSession : jest . fn ( ) ,
1110} ) ) ;
1211jest . mock ( "../hooks/usePayPal" , ( ) => ( {
1312 usePayPal : jest . fn ( ) ,
1413} ) ) ;
15- jest . mock ( "../hooks/useEligibleMethods" , ( ) => ( {
16- useEligibleMethods : jest . fn ( ) ,
17- } ) ) ;
1814
1915describe ( "PayLaterOneTimePaymentButton" , ( ) => {
2016 const mockHandleClick = jest . fn ( ) ;
2117 const mockUsePayLaterOneTimePaymentSession =
2218 usePayLaterOneTimePaymentSession as jest . Mock ;
2319 const mockUsePayPal = usePayPal as jest . Mock ;
24- const mockUseEligibleMethods = useEligibleMethods as jest . Mock ;
2520
2621 beforeEach ( ( ) => {
2722 jest . clearAllMocks ( ) ;
@@ -31,12 +26,8 @@ describe("PayLaterOneTimePaymentButton", () => {
3126 handleClick : mockHandleClick ,
3227 } ) ;
3328 mockUsePayPal . mockReturnValue ( {
34- isHydrated : true ,
35- } ) ;
36- mockUseEligibleMethods . mockReturnValue ( {
3729 eligiblePaymentMethods : null ,
38- isLoading : false ,
39- error : null ,
30+ isHydrated : true ,
4031 } ) ;
4132 } ) ;
4233
@@ -170,7 +161,7 @@ describe("PayLaterOneTimePaymentButton", () => {
170161
171162 describe ( "auto-population from eligibility context" , ( ) => {
172163 it ( "should auto-populate countryCode and productCode from eligibility context" , ( ) => {
173- mockUseEligibleMethods . mockReturnValue ( {
164+ mockUsePayPal . mockReturnValue ( {
174165 eligiblePaymentMethods : {
175166 isEligible : jest . fn ( ) . mockReturnValue ( true ) ,
176167 getDetails : jest . fn ( ) . mockReturnValue ( {
@@ -179,8 +170,7 @@ describe("PayLaterOneTimePaymentButton", () => {
179170 canBeVaulted : false ,
180171 } ) ,
181172 } ,
182- isLoading : false ,
183- error : null ,
173+ isHydrated : true ,
184174 } ) ;
185175
186176 const { container } = render (
@@ -197,10 +187,9 @@ describe("PayLaterOneTimePaymentButton", () => {
197187 } ) ;
198188
199189 it ( "should handle when eligibility was not fetched" , ( ) => {
200- mockUseEligibleMethods . mockReturnValue ( {
190+ mockUsePayPal . mockReturnValue ( {
201191 eligiblePaymentMethods : null ,
202- isLoading : false ,
203- error : null ,
192+ isHydrated : true ,
204193 } ) ;
205194
206195 const { container } = render (
@@ -217,13 +206,12 @@ describe("PayLaterOneTimePaymentButton", () => {
217206 } ) ;
218207
219208 it ( "should handle when PayLater details are not available" , ( ) => {
220- mockUseEligibleMethods . mockReturnValue ( {
209+ mockUsePayPal . mockReturnValue ( {
221210 eligiblePaymentMethods : {
222211 isEligible : jest . fn ( ) . mockReturnValue ( false ) ,
223212 getDetails : jest . fn ( ) . mockReturnValue ( undefined ) ,
224213 } ,
225- isLoading : false ,
226- error : null ,
214+ isHydrated : true ,
227215 } ) ;
228216
229217 const { container } = render (
0 commit comments