-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2005307
commit a39968c
Showing
11 changed files
with
77 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Counter from './Counter'; | ||
import '../App.css'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<h1>Welcome to my website!</h1> | ||
<Counter /> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { useState } from "react"; | ||
|
||
export default function Counter() { | ||
const [count, setCount] = useState(0); | ||
function increment() { | ||
setCount((count) => count + 1); | ||
} | ||
function decrement() { | ||
setCount((count) => count - 1); | ||
} | ||
return ( | ||
<div> | ||
<h2>Counter</h2> | ||
<p data-testid="count">{count}</p> | ||
<button onClick={increment}> + </button> | ||
<button onClick={decrement}> - </button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import './index.css'; | ||
import App from './App'; | ||
import reportWebVitals from './reportWebVitals'; | ||
import App from './components/App'; | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root')); | ||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); | ||
|
||
// If you want to start measuring performance in your app, pass a function | ||
// to log results (for example: reportWebVitals(console.log)) | ||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
reportWebVitals(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import App from '../components/App'; | ||
|
||
test('renders welcome message', () => { | ||
render(<App />); | ||
const welcomeMessage = screen.getByText(/Welcome to my website!/i); | ||
expect(welcomeMessage).toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// import necessary react testing library helpers here | ||
// import the Counter component here | ||
|
||
beforeEach(() => { | ||
// Render the Counter component here | ||
}) | ||
|
||
test('renders counter message', () => { | ||
// Complete the unit test below based on the objective in the line above | ||
}); | ||
|
||
test('should render initial count with value of 0', () => { | ||
// Complete the unit test below based on the objective in the line above | ||
}); | ||
|
||
test('clicking + increments the count', () => { | ||
// Complete the unit test below based on the objective in the line above | ||
}); | ||
|
||
test('clicking - decrements the count', () => { | ||
// Complete the unit test below based on the objective in the line above | ||
}); |