@@ -38,26 +38,27 @@ describe( 'useDomainToPlanCreditsApplicable', () => {
38
38
mockIsCurrentPlanPaid . mockImplementation ( ( ) => false ) ;
39
39
} ) ;
40
40
41
- test ( 'Returns credit when site has a domain, is on a free plan, and has credits ' , ( ) => {
41
+ test ( 'Returns the credit value for a site that is eligible ( has a domain and is on the free plan) ' , ( ) => {
42
42
const { result } = renderHookWithProvider ( ( ) => useDomainToPlanCreditsApplicable ( siteId ) ) ;
43
43
expect ( result . current ) . toEqual ( 1000 ) ;
44
44
} ) ;
45
45
46
- test ( 'Returns credit when credit value is 0' , ( ) => {
47
- mockUseMaxPlanUpgradeCredits . mockImplementation ( ( ) => 0 ) ;
48
- const { result } = renderHookWithProvider ( ( ) => useDomainToPlanCreditsApplicable ( siteId ) ) ;
49
- expect ( result . current ) . toEqual ( 0 ) ;
50
- } ) ;
51
-
52
- test ( 'Returns null when site has no domain' , ( ) => {
46
+ test ( "Returns null when the site is not eligible because it doesn't have a domain)" , ( ) => {
53
47
mockHasPurchasedDomain . mockImplementation ( ( ) => false ) ;
54
48
const { result } = renderHookWithProvider ( ( ) => useDomainToPlanCreditsApplicable ( siteId ) ) ;
55
49
expect ( result . current ) . toEqual ( null ) ;
56
50
} ) ;
57
51
58
- test ( 'Returns null when site is on a paid plan' , ( ) => {
52
+ test ( 'Returns null when the site is not eligible because it is on a paid plan' , ( ) => {
59
53
mockIsCurrentPlanPaid . mockImplementation ( ( ) => true ) ;
60
54
const { result } = renderHookWithProvider ( ( ) => useDomainToPlanCreditsApplicable ( siteId ) ) ;
61
55
expect ( result . current ) . toEqual ( null ) ;
62
56
} ) ;
57
+
58
+ test ( 'Returns 0 (rather than null) for for a site that is eligible and has a credit value of 0' , ( ) => {
59
+ // ie. distinguishes between a site having zero credits, and a site being ineligible for credits (returning null)
60
+ mockUseMaxPlanUpgradeCredits . mockImplementation ( ( ) => 0 ) ;
61
+ const { result } = renderHookWithProvider ( ( ) => useDomainToPlanCreditsApplicable ( siteId ) ) ;
62
+ expect ( result . current ) . toEqual ( 0 ) ;
63
+ } ) ;
63
64
} ) ;
0 commit comments