Skip to content

Commit

Permalink
update test to exclude timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
dayhaysoos committed Jan 1, 2024
1 parent 567d0bb commit 331c425
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions use-shopping-cart/core/slice.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion use-shopping-cart/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -123,3 +123,4 @@
"uuid": "^8.3.2"
}
}

0 comments on commit 331c425

Please sign in to comment.