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
it('should show water bottles when a user navigates to `product/water-bottles`', () => { | |
const { findByText } = renderWithRouterMatch( | |
<ProductPage />, | |
{ | |
path: '/:product', | |
route: '/water-bottles/' | |
}, | |
{ store = {} } | |
); |
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 path = require('path'); | |
const templatesPath = path.resolve(__dirname, 'templates'); // this is the path to our templates | |
const consumerPath = process.cwd(); // returns the current working directory | |
module.exports = (plop) => { | |
plop.setGenerator('component', componentPrompts({ templatesPath, consumerPath })); | |
}; |
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
module.exports = (plop) => { | |
require('component-generator-library')(plop); | |
}; |
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
Show hidden characters
{ | |
"presets": [ | |
[ | |
"@babel/preset-env", | |
{ | |
"useBuiltIns": false | |
} | |
] | |
], | |
"plugins": ["@babel/plugin-transform-runtime"] |
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 Cart = ({items}) => { | |
const dispatch = useDispatch() | |
const isLoggedIn = useSelector((state) => state.account.isLoggedIn) | |
const clearCart = () => { | |
dispatch(reduxActionToClearCart()) | |
} | |
if(!isLoggedIn){ |
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 Cart = ({items, isLoggedIn, btnCallBack}) => { | |
if(!isLoggedIn){ | |
return <LoginPrompt/> | |
} | |
return( | |
<div> | |
<div> | |
{items.map(({price, name}) => { |
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 ShoppingCart = () => { | |
const [errorMessage, setErrorMessage] = useState(null) | |
const isLoggedIn = useSelector((state) => state.account.isLoggedIn); | |
const urlToUse = isLoggedIn ? 'https://api/customercheckout' : 'https://api/guestcheckout'; | |
const addToCartFunction = async (items) => { | |
const { data, errors } = await axios.post(urlToUse, {items}); | |
if(errors){ |
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 apiClient from './apiClient'; | |
import ShoppingCart from './ShoppingCart'; | |
const ShoppingCartContainer = ({apiClient}) => { | |
const [errorMessage, setErrorMessage] = useState(null) | |
const isLoggedIn = useSelector((state) => state.account.isLoggedIn); | |
const urlToUse = isLoggedIn ? 'https://api/customercheckout' : 'https://api/guestcheckout'; | |
const addToCartFunction = async (items) => { |
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 axios = require('axios'); | |
const flattenArr = (arr) => { | |
const retVal = []; | |
const helper = (val) => { | |
for (let i = 0; i < val.length; i++) { | |
if (Array.isArray(val[i])) { | |
helper(val[i]); | |
} else { |
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 { flattenArr, dataFetcher, createList } = require('./myFunc'); | |
const axios = require('axios'); | |
jest.mock('axios', () => ({ | |
get: jest.fn(), | |
})); | |
describe.skip('flattenArr', () => { | |
it('return a non-nested arr', () => { | |
const input = [1, 2, 3, 4]; |