@automattic/plans-grid-next 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/cjs/components/comparison-grid/index.js +48 -25
  2. package/dist/cjs/components/comparison-grid/index.js.map +1 -1
  3. package/dist/cjs/components/comparison-grid/index.stories.js.map +1 -1
  4. package/dist/cjs/components/features-grid/index.js.map +1 -1
  5. package/dist/cjs/components/features-grid/style.scss +4 -2
  6. package/dist/cjs/components/plan-button/style.scss +4 -4
  7. package/dist/cjs/components/shared/header-price/style.scss +2 -0
  8. package/dist/cjs/hooks/data-store/use-plan-billing-period.js +14 -0
  9. package/dist/cjs/hooks/data-store/use-plan-billing-period.js.map +1 -0
  10. package/dist/cjs/hooks/use-grid-size.js.map +1 -1
  11. package/dist/cjs/index.js +3 -1
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/esm/components/comparison-grid/index.js +48 -25
  14. package/dist/esm/components/comparison-grid/index.js.map +1 -1
  15. package/dist/esm/components/comparison-grid/index.stories.js.map +1 -1
  16. package/dist/esm/components/features-grid/index.js.map +1 -1
  17. package/dist/esm/components/features-grid/style.scss +4 -2
  18. package/dist/esm/components/plan-button/style.scss +4 -4
  19. package/dist/esm/components/shared/header-price/style.scss +2 -0
  20. package/dist/esm/hooks/data-store/use-plan-billing-period.js +12 -0
  21. package/dist/esm/hooks/data-store/use-plan-billing-period.js.map +1 -0
  22. package/dist/esm/hooks/use-grid-size.js.map +1 -1
  23. package/dist/esm/index.js +2 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/dist/types/components/comparison-grid/index.d.ts.map +1 -1
  28. package/dist/types/components/comparison-grid/index.stories.d.ts +2 -2
  29. package/dist/types/components/dropdown-option.d.ts.map +1 -1
  30. package/dist/types/components/features-grid/billing-timeframes.d.ts.map +1 -1
  31. package/dist/types/components/features-grid/client-logo-list/index.d.ts.map +1 -1
  32. package/dist/types/components/features-grid/enterprise-features.d.ts.map +1 -1
  33. package/dist/types/components/features-grid/index.d.ts.map +1 -1
  34. package/dist/types/components/features-grid/mobile-free-domain.d.ts.map +1 -1
  35. package/dist/types/components/features-grid/plan-features-list.d.ts.map +1 -1
  36. package/dist/types/components/features-grid/plan-headers.d.ts.map +1 -1
  37. package/dist/types/components/features-grid/plan-logos.d.ts.map +1 -1
  38. package/dist/types/components/features-grid/plan-prices.d.ts.map +1 -1
  39. package/dist/types/components/features-grid/plan-tagline.d.ts.map +1 -1
  40. package/dist/types/components/features-grid/previous-features-included-title.d.ts.map +1 -1
  41. package/dist/types/components/features-grid/spotlight-plan.d.ts.map +1 -1
  42. package/dist/types/components/features-grid/table.d.ts.map +1 -1
  43. package/dist/types/components/features-grid/top-buttons.d.ts.map +1 -1
  44. package/dist/types/components/plan-button/index.d.ts.map +1 -1
  45. package/dist/types/components/plan-div-td-container.d.ts.map +1 -1
  46. package/dist/types/components/plans-2023-tooltip.d.ts.map +1 -1
  47. package/dist/types/components/shared/action-button/index.d.ts.map +1 -1
  48. package/dist/types/components/shared/billing-timeframe/index.d.ts.map +1 -1
  49. package/dist/types/components/shared/header-price/header-price-context.d.ts.map +1 -1
  50. package/dist/types/components/shared/header-price/index.d.ts.map +1 -1
  51. package/dist/types/components/shared/storage/components/plan-storage.d.ts.map +1 -1
  52. package/dist/types/components/shared/storage/components/storage-dropdown.d.ts.map +1 -1
  53. package/dist/types/components/shared/storage/components/storage-feature-label.d.ts.map +1 -1
  54. package/dist/types/css-mixins.d.ts.map +1 -1
  55. package/dist/types/grid-context.d.ts.map +1 -1
  56. package/dist/types/hooks/data-store/use-grid-plan-for-spotlight.d.ts.map +1 -1
  57. package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts.map +1 -1
  58. package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts.map +1 -1
  59. package/dist/types/hooks/data-store/use-grid-plans.d.ts.map +1 -1
  60. package/dist/types/hooks/data-store/use-highlight-labels.d.ts.map +1 -1
  61. package/dist/types/hooks/data-store/use-plan-billing-period.d.ts +8 -0
  62. package/dist/types/hooks/data-store/use-plan-billing-period.d.ts.map +1 -0
  63. package/dist/types/hooks/data-store/use-plans-from-types.d.ts.map +1 -1
  64. package/dist/types/hooks/use-grid-size.d.ts +3 -2
  65. package/dist/types/hooks/use-grid-size.d.ts.map +1 -1
  66. package/dist/types/hooks/use-highlight-adjacency-matrix.d.ts.map +1 -1
  67. package/dist/types/index.d.ts +2 -1
  68. package/dist/types/index.d.ts.map +1 -1
  69. package/dist/types/lib/filter-unused-features-object.d.ts.map +1 -1
  70. package/dist/types/lib/get-plan-features-object.d.ts.map +1 -1
  71. package/dist/types/types.d.ts +4 -4
  72. package/dist/types/types.d.ts.map +1 -1
  73. package/package.json +3 -2
  74. package/src/components/comparison-grid/index.stories.tsx +1 -1
  75. package/src/components/comparison-grid/index.tsx +56 -28
  76. package/src/components/features-grid/index.tsx +2 -1
  77. package/src/components/features-grid/style.scss +4 -2
  78. package/src/components/plan-button/style.scss +4 -4
  79. package/src/components/shared/header-price/style.scss +2 -0
  80. package/src/hooks/data-store/use-plan-billing-period.tsx +28 -0
  81. package/src/hooks/use-grid-size.ts +3 -2
  82. package/src/index.tsx +2 -0
  83. package/src/types.ts +4 -4
  84. package/dist/cjs/lib/sort-plan-properties.js +0 -26
  85. package/dist/cjs/lib/sort-plan-properties.js.map +0 -1
  86. package/dist/esm/lib/sort-plan-properties.js +0 -23
  87. package/dist/esm/lib/sort-plan-properties.js.map +0 -1
  88. package/dist/types/lib/sort-plan-properties.d.ts +0 -3
  89. package/dist/types/lib/sort-plan-properties.d.ts.map +0 -1
  90. package/src/lib/sort-plan-properties.ts +0 -27
  91. package/src/lib/test/sort-plan-properties.ts +0 -122
@@ -31,6 +31,7 @@ import type {
31
31
  FeaturesGridExternalProps,
32
32
  FeaturesGridProps,
33
33
  GridPlan,
34
+ GridSize,
34
35
  PlanActionOverrides,
35
36
  } from '../../types';
36
37
 
@@ -405,7 +406,7 @@ const WrappedFeaturesGrid = ( props: FeaturesGridExternalProps ) => {
405
406
  // we want to fit 3 plans per row in this breakpoint
406
407
  const mediumBreakpoint = isInSiteDashboard ? 667 : 741;
407
408
 
408
- return new Map( [
409
+ return new Map< GridSize, number >( [
409
410
  [ 'small', 0 ],
410
411
  [ 'medium', mediumBreakpoint ],
411
412
  [ 'large', largeBreakpoint ],
@@ -241,8 +241,10 @@
241
241
  &.is-top-buttons {
242
242
  padding: 0 20px;
243
243
  @include plans-grid-medium-large {
244
- padding-top: 16px;
245
- padding-bottom: 16px;
244
+ button {
245
+ margin-top: 16px;
246
+ margin-bottom: 16px;
247
+ }
246
248
  }
247
249
  }
248
250
 
@@ -21,7 +21,7 @@
21
21
  box-shadow: 0 0 0 2px var(--studio-white), 0 0 0 4px var(--studio-wordpress-blue-50);
22
22
  }
23
23
 
24
- &:hover {
24
+ &:hover:not([disabled]) {
25
25
  background-color: var(--studio-wordpress-blue-60);
26
26
  }
27
27
 
@@ -34,7 +34,7 @@
34
34
  box-shadow: 0 0 0 2px var(--studio-white), 0 0 0 4px var(--studio-wordpress-blue-60);
35
35
  }
36
36
 
37
- &:hover {
37
+ &:hover:not([disabled]) {
38
38
  background-color: var(--studio-wordpress-blue-70);
39
39
  }
40
40
  }
@@ -46,7 +46,7 @@
46
46
  box-shadow: 0 0 0 2px var(--studio-white), 0 0 0 4px var(--studio-wordpress-blue-70);
47
47
  }
48
48
 
49
- &:hover {
49
+ &:hover:not([disabled]) {
50
50
  background-color: var(--studio-wordpress-blue-80);
51
51
  }
52
52
  }
@@ -58,7 +58,7 @@
58
58
  box-shadow: 0 0 0 2px var(--studio-white), 0 0 0 4px var(--studio-woocommerce-purple-60);
59
59
  }
60
60
 
61
- &:hover {
61
+ &:hover:not([disabled]) {
62
62
  background-color: var(--studio-woocommerce-purple-70);
63
63
  }
64
64
 
@@ -1,3 +1,5 @@
1
+ @import "@automattic/typography/styles/variables";
2
+
1
3
  .plans-grid-next-header-price {
2
4
  padding: 0 20px;
3
5
  margin: 0 0 4px 0;
@@ -0,0 +1,28 @@
1
+ import {
2
+ TERMS_LIST,
3
+ TERM_ANNUALLY,
4
+ TERM_BIENNIALLY,
5
+ TERM_MONTHLY,
6
+ TERM_TRIENNIALLY,
7
+ } from '@automattic/calypso-products';
8
+ import { EFFECTIVE_TERMS_LIST } from '../../constants';
9
+ import type { SupportedUrlFriendlyTermType } from '../../types';
10
+
11
+ const usePlanBillingPeriod = ( {
12
+ intervalType,
13
+ defaultValue,
14
+ }: {
15
+ intervalType: SupportedUrlFriendlyTermType;
16
+ defaultValue?: ( typeof TERMS_LIST )[ number ];
17
+ } ) => {
18
+ const plans: Record< SupportedUrlFriendlyTermType, ( typeof EFFECTIVE_TERMS_LIST )[ number ] > = {
19
+ monthly: TERM_MONTHLY,
20
+ yearly: TERM_ANNUALLY,
21
+ '2yearly': TERM_BIENNIALLY,
22
+ '3yearly': TERM_TRIENNIALLY,
23
+ } as const;
24
+
25
+ return plans[ intervalType ] || defaultValue || TERM_ANNUALLY;
26
+ };
27
+
28
+ export default usePlanBillingPeriod;
@@ -1,4 +1,5 @@
1
1
  import { useLayoutEffect, useState } from '@wordpress/element';
2
+ import { GridSize } from '../types';
2
3
 
3
4
  interface Props {
4
5
  containerRef: React.MutableRefObject< HTMLDivElement | null >;
@@ -8,7 +9,7 @@ interface Props {
8
9
  * but they could be used in the future in a containment context.
9
10
  * The keys are the labels, the values are the minimum widths.
10
11
  */
11
- containerBreakpoints: Map< string, number >;
12
+ containerBreakpoints: Map< GridSize, number >;
12
13
  }
13
14
 
14
15
  /**
@@ -16,7 +17,7 @@ interface Props {
16
17
  * and the breakpoints passed through as props.
17
18
  */
18
19
  export default function useGridSize( { containerRef, containerBreakpoints }: Props ) {
19
- const [ gridSize, setGridSize ] = useState< string | null >( null );
20
+ const [ gridSize, setGridSize ] = useState< GridSize | null >( null );
20
21
 
21
22
  useLayoutEffect( () => {
22
23
  if ( ! containerRef.current ) {
package/src/index.tsx CHANGED
@@ -9,6 +9,7 @@ import useGridPlans, { usePlanTypesWithIntent } from './hooks/data-store/use-gri
9
9
  import useGridPlansForComparisonGrid from './hooks/data-store/use-grid-plans-for-comparison-grid';
10
10
  import useGridPlansForFeaturesGrid from './hooks/data-store/use-grid-plans-for-features-grid';
11
11
  import usePlanBillingDescription from './hooks/data-store/use-plan-billing-description';
12
+ import usePlanBillingPeriod from './hooks/data-store/use-plan-billing-period';
12
13
  import usePlanFeaturesForGridPlans from './hooks/data-store/use-plan-features-for-grid-plans';
13
14
  import usePlansFromTypes from './hooks/data-store/use-plans-from-types';
14
15
  import useRestructuredPlanFeaturesForComparisonGrid from './hooks/data-store/use-restructured-plan-features-for-comparison-grid';
@@ -33,6 +34,7 @@ export {
33
34
  useGridPlansForFeaturesGrid,
34
35
  useGridPlansForComparisonGrid,
35
36
  useGridPlanForSpotlight,
37
+ usePlanBillingPeriod,
36
38
  usePlanBillingDescription,
37
39
  usePlanFeaturesForGridPlans,
38
40
  usePlansFromTypes,
package/src/types.ts CHANGED
@@ -51,7 +51,7 @@ export interface GridPlan {
51
51
  * Grid Component Types:
52
52
  ***********************/
53
53
 
54
- export type GridSize = 'small' | 'medium' | 'large';
54
+ export type GridSize = 'small' | 'smedium' | 'medium' | 'large' | 'xlarge';
55
55
 
56
56
  export type PlansIntent =
57
57
  | 'plans-affiliate'
@@ -106,7 +106,7 @@ export interface CommonGridProps {
106
106
  isInAdmin: boolean;
107
107
  isInSiteDashboard: boolean;
108
108
  onStorageAddOnClick?: ( addOnSlug: AddOns.StorageAddOnSlug ) => void;
109
- currentSitePlanSlug?: string | null;
109
+ currentSitePlanSlug?: PlanSlug | null;
110
110
  hideUnavailableFeatures?: boolean; // used to hide features that are not available, instead of strike-through as explained in #76206
111
111
  planActionOverrides?: PlanActionOverrides;
112
112
  // Value of the `?feature=` query param, so we can highlight a given feature and hide plans without it.
@@ -117,7 +117,7 @@ export interface CommonGridProps {
117
117
  // only used for comparison grid
118
118
  planTypeSelectorProps?: PlanTypeSelectorProps;
119
119
  gridContainerRef?: React.MutableRefObject< HTMLDivElement | null >;
120
- gridSize?: string;
120
+ gridSize?: GridSize;
121
121
  }
122
122
 
123
123
  export interface FeaturesGridProps extends CommonGridProps {
@@ -134,7 +134,7 @@ export interface FeaturesGridProps extends CommonGridProps {
134
134
  export interface ComparisonGridProps extends CommonGridProps {
135
135
  // Value of the `?plan=` query param, so we can highlight a given plan.
136
136
  selectedPlan?: string;
137
- intervalType: string;
137
+ intervalType: SupportedUrlFriendlyTermType;
138
138
  }
139
139
 
140
140
  export type UseActionCallback = ( {
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sortPlans = sortPlans;
4
- function sortPlans(gridPlans, currentSitePlanProductSlug) {
5
- // If we don't have plans to sort, return empty array
6
- if (!gridPlans.length) {
7
- return [];
8
- }
9
- // If we have a current site plan and we're on mobile, sort to prioritize it
10
- if (currentSitePlanProductSlug) {
11
- return [...gridPlans].sort((planA, planB) => {
12
- // If planA is the current plan, it should come first (-1 moves it up)
13
- if (planA.planSlug === currentSitePlanProductSlug) {
14
- return -1;
15
- }
16
- // If planB is the current plan, it should come first (1 moves planA down)
17
- if (planB.planSlug === currentSitePlanProductSlug) {
18
- return 1;
19
- }
20
- // Otherwise, maintain original order
21
- return 0;
22
- });
23
- }
24
- return [...gridPlans];
25
- }
26
- //# sourceMappingURL=sort-plan-properties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sort-plan-properties.js","sourceRoot":"","sources":["../../../src/lib/sort-plan-properties.ts"],"names":[],"mappings":";;AAEA,8BAwBC;AAxBD,SAAgB,SAAS,CACxB,SAAqB,EACrB,0BAA0C;IAE1C,qDAAqD;IACrD,IAAK,CAAE,SAAS,CAAC,MAAM,EAAG,CAAC;QAC1B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,4EAA4E;IAC5E,IAAK,0BAA0B,EAAG,CAAC;QAClC,OAAO,CAAE,GAAG,SAAS,CAAE,CAAC,IAAI,CAAE,CAAE,KAAK,EAAE,KAAK,EAAG,EAAE;YAChD,sEAAsE;YACtE,IAAK,KAAK,CAAC,QAAQ,KAAK,0BAA0B,EAAG,CAAC;gBACrD,OAAO,CAAC,CAAC,CAAC;YACX,CAAC;YACD,0EAA0E;YAC1E,IAAK,KAAK,CAAC,QAAQ,KAAK,0BAA0B,EAAG,CAAC;gBACrD,OAAO,CAAC,CAAC;YACV,CAAC;YACD,qCAAqC;YACrC,OAAO,CAAC,CAAC;QACV,CAAC,CAAE,CAAC;IACL,CAAC;IACD,OAAO,CAAE,GAAG,SAAS,CAAE,CAAC;AACzB,CAAC"}
@@ -1,23 +0,0 @@
1
- export function sortPlans(gridPlans, currentSitePlanProductSlug) {
2
- // If we don't have plans to sort, return empty array
3
- if (!gridPlans.length) {
4
- return [];
5
- }
6
- // If we have a current site plan and we're on mobile, sort to prioritize it
7
- if (currentSitePlanProductSlug) {
8
- return [...gridPlans].sort((planA, planB) => {
9
- // If planA is the current plan, it should come first (-1 moves it up)
10
- if (planA.planSlug === currentSitePlanProductSlug) {
11
- return -1;
12
- }
13
- // If planB is the current plan, it should come first (1 moves planA down)
14
- if (planB.planSlug === currentSitePlanProductSlug) {
15
- return 1;
16
- }
17
- // Otherwise, maintain original order
18
- return 0;
19
- });
20
- }
21
- return [...gridPlans];
22
- }
23
- //# sourceMappingURL=sort-plan-properties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sort-plan-properties.js","sourceRoot":"","sources":["../../../src/lib/sort-plan-properties.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,SAAS,CACxB,SAAqB,EACrB,0BAA0C;IAE1C,qDAAqD;IACrD,IAAK,CAAE,SAAS,CAAC,MAAM,EAAG,CAAC;QAC1B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,4EAA4E;IAC5E,IAAK,0BAA0B,EAAG,CAAC;QAClC,OAAO,CAAE,GAAG,SAAS,CAAE,CAAC,IAAI,CAAE,CAAE,KAAK,EAAE,KAAK,EAAG,EAAE;YAChD,sEAAsE;YACtE,IAAK,KAAK,CAAC,QAAQ,KAAK,0BAA0B,EAAG,CAAC;gBACrD,OAAO,CAAC,CAAC,CAAC;YACX,CAAC;YACD,0EAA0E;YAC1E,IAAK,KAAK,CAAC,QAAQ,KAAK,0BAA0B,EAAG,CAAC;gBACrD,OAAO,CAAC,CAAC;YACV,CAAC;YACD,qCAAqC;YACrC,OAAO,CAAC,CAAC;QACV,CAAC,CAAE,CAAC;IACL,CAAC;IACD,OAAO,CAAE,GAAG,SAAS,CAAE,CAAC;AACzB,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { GridPlan } from '../types';
2
- export declare function sortPlans(gridPlans: GridPlan[], currentSitePlanProductSlug?: string | null): GridPlan[];
3
- //# sourceMappingURL=sort-plan-properties.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sort-plan-properties.d.ts","sourceRoot":"","sources":["../../../src/lib/sort-plan-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,SAAS,CACxB,SAAS,EAAE,QAAQ,EAAE,EACrB,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,GACxC,QAAQ,EAAE,CAqBZ"}
@@ -1,27 +0,0 @@
1
- import type { GridPlan } from '../types';
2
-
3
- export function sortPlans(
4
- gridPlans: GridPlan[],
5
- currentSitePlanProductSlug?: string | null
6
- ): GridPlan[] {
7
- // If we don't have plans to sort, return empty array
8
- if ( ! gridPlans.length ) {
9
- return [];
10
- }
11
- // If we have a current site plan and we're on mobile, sort to prioritize it
12
- if ( currentSitePlanProductSlug ) {
13
- return [ ...gridPlans ].sort( ( planA, planB ) => {
14
- // If planA is the current plan, it should come first (-1 moves it up)
15
- if ( planA.planSlug === currentSitePlanProductSlug ) {
16
- return -1;
17
- }
18
- // If planB is the current plan, it should come first (1 moves planA down)
19
- if ( planB.planSlug === currentSitePlanProductSlug ) {
20
- return 1;
21
- }
22
- // Otherwise, maintain original order
23
- return 0;
24
- } );
25
- }
26
- return [ ...gridPlans ];
27
- }
@@ -1,122 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- /**
5
- * Default mock implementations
6
- */
7
- jest.mock( '../../hooks/data-store/is-popular-plan', () => ( {
8
- isPopularPlan: ( planSlug ) => planSlug === 'value_bundle',
9
- } ) );
10
- jest.mock( '@automattic/calypso-products', () => ( {
11
- isFreePlan: ( planSlug ) => planSlug === 'free_plan',
12
- } ) );
13
-
14
- import { sortPlans } from '../sort-plan-properties';
15
- import type { GridPlan } from '../../types';
16
-
17
- const planFree = {
18
- pricing: { originalPrice: { full: 0, monthly: 0 } },
19
- planSlug: 'free_plan',
20
- } as GridPlan;
21
-
22
- const planPersonal = {
23
- pricing: { originalPrice: { full: 100, monthly: 0 } },
24
- planSlug: 'personal-bundle',
25
- } as GridPlan;
26
-
27
- const planPremium = {
28
- pricing: { originalPrice: { full: 200, monthly: 0 } },
29
- planSlug: 'value_bundle',
30
- } as GridPlan;
31
-
32
- const planBusiness = {
33
- pricing: { originalPrice: { full: 300, monthly: 0 } },
34
- planSlug: 'business-bundle',
35
- } as GridPlan;
36
-
37
- const planEcommerce = {
38
- pricing: { originalPrice: { full: 500, monthly: 0 } },
39
- planSlug: 'ecommerce-bundle',
40
- } as GridPlan;
41
-
42
- const plansInDefaultOrder = [ planFree, planPersonal, planPremium, planBusiness, planEcommerce ];
43
-
44
- describe( 'sortPlans', () => {
45
- it( 'should return an empty array if no plans are provided', () => {
46
- expect( sortPlans( [] ) ).toEqual( [] );
47
- } );
48
-
49
- it( 'should return the original order if no current plan is specified', () => {
50
- expect( sortPlans( plansInDefaultOrder ) ).toEqual( plansInDefaultOrder );
51
- } );
52
-
53
- it( 'should return the original order if current plan is null', () => {
54
- expect( sortPlans( plansInDefaultOrder, null ) ).toEqual( plansInDefaultOrder );
55
- } );
56
-
57
- it( 'should return the original order if current plan is undefined', () => {
58
- expect( sortPlans( plansInDefaultOrder, undefined ) ).toEqual( plansInDefaultOrder );
59
- } );
60
-
61
- it( 'should return the original order if current plan is not found in the plans array', () => {
62
- expect( sortPlans( plansInDefaultOrder, 'non-existent-plan' ) ).toEqual( plansInDefaultOrder );
63
- } );
64
-
65
- it( 'should prioritize the current plan when specified', () => {
66
- // When personal plan is current
67
- expect( sortPlans( plansInDefaultOrder, 'personal-bundle' ) ).toEqual( [
68
- planPersonal,
69
- planFree,
70
- planPremium,
71
- planBusiness,
72
- planEcommerce,
73
- ] );
74
-
75
- // When premium plan is current
76
- expect( sortPlans( plansInDefaultOrder, 'value_bundle' ) ).toEqual( [
77
- planPremium,
78
- planFree,
79
- planPersonal,
80
- planBusiness,
81
- planEcommerce,
82
- ] );
83
-
84
- // When business plan is current
85
- expect( sortPlans( plansInDefaultOrder, 'business-bundle' ) ).toEqual( [
86
- planBusiness,
87
- planFree,
88
- planPersonal,
89
- planPremium,
90
- planEcommerce,
91
- ] );
92
-
93
- // When ecommerce plan is current
94
- expect( sortPlans( plansInDefaultOrder, 'ecommerce-bundle' ) ).toEqual( [
95
- planEcommerce,
96
- planFree,
97
- planPersonal,
98
- planPremium,
99
- planBusiness,
100
- ] );
101
-
102
- // When free plan is current
103
- expect( sortPlans( plansInDefaultOrder, 'free_plan' ) ).toEqual( [
104
- planFree,
105
- planPersonal,
106
- planPremium,
107
- planBusiness,
108
- planEcommerce,
109
- ] );
110
- } );
111
-
112
- it( 'should work with a single plan', () => {
113
- const singlePlan = [ planFree ];
114
- expect( sortPlans( singlePlan, 'free_plan' ) ).toEqual( [ planFree ] );
115
- } );
116
-
117
- it( 'should preserve the original array', () => {
118
- const originalArray = [ ...plansInDefaultOrder ];
119
- sortPlans( plansInDefaultOrder, 'personal-bundle' );
120
- expect( plansInDefaultOrder ).toEqual( originalArray );
121
- } );
122
- } );