first unit test
This commit is contained in:
parent
79eeac6e5c
commit
8d25159d0c
@ -1,4 +1,10 @@
|
||||
import RestaurantScreen from './components/RestaurantScreen';
|
||||
export default function App()
|
||||
{
|
||||
return <div>Hello, World</div>
|
||||
return
|
||||
(
|
||||
<div>
|
||||
<RestaurantScreen />
|
||||
</div>
|
||||
)
|
||||
}
|
11
src/components/RestaurantList.js
Normal file
11
src/components/RestaurantList.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function RestaurantList({ loadRestaurants })
|
||||
{
|
||||
useEffect(() => { loadRestaurants(); }, [loadRestaurants]);
|
||||
return
|
||||
(
|
||||
|
||||
<div>RestaurantList</div>
|
||||
)
|
||||
}
|
12
src/components/RestaurantList.spec.js
Normal file
12
src/components/RestaurantList.spec.js
Normal 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();
|
||||
});
|
||||
});
|
13
src/components/RestaurantScreen.js
Normal file
13
src/components/RestaurantScreen.js
Normal file
@ -0,0 +1,13 @@
|
||||
import RestaurantList from "./RestaurantList";
|
||||
|
||||
export default function RestaurantScreen()
|
||||
{
|
||||
return
|
||||
(
|
||||
<div>
|
||||
<h1>Restaurants</h1>
|
||||
<RestaurantList />
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user