From 331c425f1ec3d72ee205c9fbc0ef25792676f3b0 Mon Sep 17 00:00:00 2001 From: Nick DeJesus Date: Sun, 31 Dec 2023 19:58:01 -0500 Subject: [PATCH] update test to exclude timestamp --- use-shopping-cart/core/slice.test.js | 12 +++++++++--- use-shopping-cart/package.json | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/use-shopping-cart/core/slice.test.js b/use-shopping-cart/core/slice.test.js index 2069867..e9dab42 100644 --- a/use-shopping-cart/core/slice.test.js +++ b/use-shopping-cart/core/slice.test.js @@ -236,15 +236,21 @@ describe('removeItem', () => { }) describe('loadCart', () => { - it('properly merges a new cartDetails into the current cartDetails', () => { + it('properly merges a new cartDetails into the current cartDetails excluding timestamp', () => { const cart1 = mockCart() const cart2 = mockCart(undefined, { name: 'Carrots' }, { name: 'Broccoli' }) + // Destructure to exclude the timestamp from both cartDetails + const { timestamp: timestamp1, ...cart1DetailsWithoutTimestamp } = + cart1.cartDetails + const { timestamp: timestamp2, ...cart2DetailsWithoutTimestamp } = + cart2.cartDetails + const result = reducer(cart1, actions.loadCart(cart2.cartDetails)) expect(result.cartDetails).toEqual({ - ...cart1.cartDetails, - ...cart2.cartDetails + ...cart1DetailsWithoutTimestamp, + ...cart2DetailsWithoutTimestamp }) expect(result.totalPrice).toBe(3600) expect(result.cartCount).toBe(12) diff --git a/use-shopping-cart/package.json b/use-shopping-cart/package.json index 1e24ba2..cba14e1 100644 --- a/use-shopping-cart/package.json +++ b/use-shopping-cart/package.json @@ -1,6 +1,6 @@ { "name": "use-shopping-cart", - "version": "3.2.0-alpha.1", + "version": "3.2.0", "description": "Shopping cart state and logic for Stripe", "author": "dayhaysoos", "license": "MIT", @@ -123,3 +123,4 @@ "uuid": "^8.3.2" } } +