Skip to content

Commit 331c425

Browse files
committed
update test to exclude timestamp
1 parent 567d0bb commit 331c425

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

use-shopping-cart/core/slice.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,21 @@ describe('removeItem', () => {
236236
})
237237

238238
describe('loadCart', () => {
239-
it('properly merges a new cartDetails into the current cartDetails', () => {
239+
it('properly merges a new cartDetails into the current cartDetails excluding timestamp', () => {
240240
const cart1 = mockCart()
241241
const cart2 = mockCart(undefined, { name: 'Carrots' }, { name: 'Broccoli' })
242242

243+
// Destructure to exclude the timestamp from both cartDetails
244+
const { timestamp: timestamp1, ...cart1DetailsWithoutTimestamp } =
245+
cart1.cartDetails
246+
const { timestamp: timestamp2, ...cart2DetailsWithoutTimestamp } =
247+
cart2.cartDetails
248+
243249
const result = reducer(cart1, actions.loadCart(cart2.cartDetails))
244250

245251
expect(result.cartDetails).toEqual({
246-
...cart1.cartDetails,
247-
...cart2.cartDetails
252+
...cart1DetailsWithoutTimestamp,
253+
...cart2DetailsWithoutTimestamp
248254
})
249255
expect(result.totalPrice).toBe(3600)
250256
expect(result.cartCount).toBe(12)

use-shopping-cart/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-shopping-cart",
3-
"version": "3.2.0-alpha.1",
3+
"version": "3.2.0",
44
"description": "Shopping cart state and logic for Stripe",
55
"author": "dayhaysoos",
66
"license": "MIT",
@@ -123,3 +123,4 @@
123123
"uuid": "^8.3.2"
124124
}
125125
}
126+

0 commit comments

Comments
 (0)