github
197 of 337 branches covered (58.46%)
Branch coverage included in aggregate %.
346 of 537 new or added lines in 12 files covered. (64.43%)
39 existing lines in 2 files now uncovered.3037 of 3579 relevant lines covered (84.86%)
3.17 hits per line
UNCOV
1
|
import React, { useEffect } from 'react'; |
|
UNCOV
2
|
import { useSelector, useDispatch } from 'react-redux'; |
× |
UNCOV
3
|
import { RootState, AppDispatch } from '../redux/store'; |
× |
UNCOV
4
|
import { fetchProducts } from '../redux/actions/productAction'; |
× |
UNCOV
5
|
|
× |
UNCOV
6
|
const ProductList: React.FC = () => {
|
× |
UNCOV
7
|
const dispatch = useDispatch<AppDispatch>();
|
× |
UNCOV
8
|
const { products, loading, error } = useSelector((state: RootState) => state.products);
|
× |
UNCOV
9
|
|
× |
UNCOV
10
|
useEffect(() => { |
× |
UNCOV
11
|
dispatch(fetchProducts()); |
× |
UNCOV
12
|
}, [dispatch]); |
× |
UNCOV
13
|
|
× |
UNCOV
14
|
if (loading) return <p>Loading...</p>; |
× |
UNCOV
15
|
if (error) return <p>Error: {error}</p>; |
× |
UNCOV
16
|
|
× |
UNCOV
17
|
return <ul>{products?.data?.products?.map((product) => <li key={product.id}>{product.name}</li>)}</ul>;
|
× |
UNCOV
18
|
}; |
× |
UNCOV
19
|
|
× |
UNCOV
20
|
export default ProductList; |
× |