Last active
September 21, 2020 19:32
-
-
Save BrianJenney/98fd1f2f951eb638e43410a3cacaa768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ProductDetail = () => { | |
const classes = useStyles(); | |
const cart = useSelector(state => state.cart); | |
const { product } = useContext(ProductContext); | |
return ( | |
<Card > | |
<CardContent> | |
<Box> | |
{product.name}: {cart.count} | |
</Box> | |
</CardContent> | |
</Card> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import '../../../test/setup'; | |
import { cleanup, fireEvent, findByText } from '@testing-library/react'; | |
import ProductDetail from './ProductDetail'; | |
describe('Product Details', () => { | |
afterEach(() => { | |
cleanup(); | |
}); | |
it('renders with default data', async () => { | |
const { queryByText, getByTestId } = render( | |
<ProductDetail product={{name: 'Cool Product'}} cart={{count: 1}} /> | |
); | |
expect(queryByText('Cool Product: 1')).toBeTruthy(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment