@lookiero/checkout 7.0.0 → 7.0.1

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.
@@ -78,9 +78,13 @@ const CheckoutMiddleware = ({ customerId, onNotAccessible, loader = React.create
78
78
  }
79
79
  }
80
80
  }, [basePath, checkout?.status, checkout?.items]);
81
- if (!checkout) {
81
+ if (checkout === undefined) {
82
82
  return loader;
83
83
  }
84
+ if (checkout === null) {
85
+ onNotAccessible();
86
+ return null;
87
+ }
84
88
  /* Prevent direct payment access */
85
89
  if (checkoutPaymentRouteMatch && !checkoutShown.current) {
86
90
  onNotAccessible();
@@ -1 +1 @@
1
- export declare const VERSION = "7.0.0";
1
+ export declare const VERSION = "7.0.1";
@@ -1 +1 @@
1
- export const VERSION = "7.0.0";
1
+ export const VERSION = "7.0.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": "false",
@@ -140,6 +140,16 @@ describe("CheckoutMiddleware component", () => {
140
140
  expect(mockStartCheckout).toHaveBeenCalled();
141
141
  });
142
142
 
143
+ it("should call onNotAccessible when no checkout is found", async () => {
144
+ (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([null, QueryStatus.SUCCESS]);
145
+ (useStartCheckout as jest.Mock).mockReturnValue([mockStartCheckout, CommandStatus.SUCCESS]);
146
+
147
+ const onNotAccessible = jest.fn();
148
+ renderCheckoutMiddleware({ path: Routes.HOME, onNotAccessible });
149
+
150
+ expect(onNotAccessible).toHaveBeenCalled();
151
+ });
152
+
143
153
  it("payment route should not be directly accessible", async () => {
144
154
  const checkoutMock = checkout({ items: [{ status: CheckoutItemStatus.INITIAL }] });
145
155
  (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, QueryStatus.SUCCESS]);
@@ -117,10 +117,16 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
117
117
  }
118
118
  }, [basePath, checkout?.status, checkout?.items]);
119
119
 
120
- if (!checkout) {
120
+ if (checkout === undefined) {
121
121
  return loader;
122
122
  }
123
123
 
124
+ if (checkout === null) {
125
+ onNotAccessible();
126
+
127
+ return null;
128
+ }
129
+
124
130
  /* Prevent direct payment access */
125
131
  if (checkoutPaymentRouteMatch && !checkoutShown.current) {
126
132
  onNotAccessible();