first unit test

This commit is contained in:
Branden Wayne Jones 2024-04-24 13:57:50 -04:00
parent 79eeac6e5c
commit 8d25159d0c
4 changed files with 43 additions and 1 deletions

View File

@ -1,4 +1,10 @@
import RestaurantScreen from './components/RestaurantScreen';
export default function App()
{
return <div>Hello, World</div>
return
(
<div>
<RestaurantScreen />
</div>
)
}

View File

@ -0,0 +1,11 @@
import { useEffect } from "react";
export default function RestaurantList({ loadRestaurants })
{
useEffect(() => { loadRestaurants(); }, [loadRestaurants]);
return
(
<div>RestaurantList</div>
)
}

View File

@ -0,0 +1,12 @@
import { render } from '@testing-library/react';
import RestaurantList from './RestaurantList';
describe('RestaurantList', () =>
{
it('loads restaurants on first render', () =>
{
const loadRestaurants = jest.fn().mockName('loadRestaurnats');
render(<RestaurantList loadRestaurants={loadRestaurants} />);
expect(loadRestaurants).toHaveBeenCalled();
});
});

View File

@ -0,0 +1,13 @@
import RestaurantList from "./RestaurantList";
export default function RestaurantScreen()
{
return
(
<div>
<h1>Restaurants</h1>
<RestaurantList />
</div>
)
}