1. Test component have useSelector / conditional render
I got information from stackOverflow, and I combine the first and third stackOverflow answers.
I also use example from github
1.1 Test conditional render
StackOverflow 1st answer: Use mockStore to test conditioner render
Original Code:
import React from 'react';
import AppRouter from './Router'
import {
useDispatch, useSelector } from 'react-redux'
import StartupActions from './Redux/Startup'
import Startup from './Components/Startup'
import './App.css';
// This is the main component, it includes the router which manages
// routing to different views.
// This is also the right place to declare components which should be
// displayed everywhere, i.e. sockets, services,...
function App () {
const dispatch = useDispatch()
const startupComplete = useSelector(state => state.startup.complete)
if (!startupComplete) {
setTimeout(() => dispatch(StartupActions.startup()), 1000)
}
return (
<div className="app">
{
startupComplete ? <AppRouter /> : <Startup />