Skip to content

Commit 8b85d7e

Browse files
YmshadAtimdorr
authored andcommitted
fix(Product): ProductItem and Cart gives different prop for product quantity (reduxjs#2770)
1 parent 263b051 commit 8b85d7e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

examples/shopping-cart/src/components/Product.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33

4-
const Product = ({ price, inventory, title }) => (
4+
const Product = ({ price, quantity, title }) => (
55
<div>
6-
{title} - &#36;{price}{inventory ? ` x ${inventory}` : null}
6+
{title} - &#36;{price}{quantity ? ` x ${quantity}` : null}
77
</div>
88
)
99

1010
Product.propTypes = {
1111
price: PropTypes.number,
12-
inventory: PropTypes.number,
12+
quantity: PropTypes.number,
1313
title: PropTypes.string
1414
}
1515

examples/shopping-cart/src/components/Product.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('Product component', () => {
2020

2121
describe('when given inventory', () => {
2222
it('should render title, price, and inventory', () => {
23-
const { component } = setup({ title: 'Test Product', price: 9.99, inventory: 6 })
23+
const { component } = setup({ title: 'Test Product', price: 9.99, quantity: 6 })
2424
expect(component.text()).toBe('Test Product - $9.99 x 6')
2525
})
2626
})

examples/shopping-cart/src/components/ProductItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ProductItem = ({ product, onAddToCartClicked }) => (
77
<Product
88
title={product.title}
99
price={product.price}
10-
inventory={product.inventory} />
10+
quantity={product.inventory} />
1111
<button
1212
onClick={onAddToCartClicked}
1313
disabled={product.inventory > 0 ? '' : 'disabled'}>

examples/shopping-cart/src/components/ProductItem.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('ProductItem component', () => {
3333

3434
it('should render product', () => {
3535
const { product } = setup(productProps)
36-
expect(product.props()).toEqual({ title: 'Product 1', price: 9.99, inventory: 6 })
36+
expect(product.props()).toEqual({ title: 'Product 1', price: 9.99, quantity: 6 })
3737
})
3838

3939
it('should render Add To Cart message', () => {

0 commit comments

Comments
 (0)