github
209 of 349 branches covered (59.89%)
Branch coverage included in aggregate %.
417 of 549 new or added lines in 13 files covered. (75.96%)
39 existing lines in 2 files now uncovered.3108 of 3591 relevant lines covered (86.55%)
3.57 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; |
× |