Skip to content

Commit 4f4defe

Browse files
committed
added a header for usability
1 parent f08a7c5 commit 4f4defe

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,4 +755,51 @@ test('should throw an exception the note array is undefined', () => {
755755
- Don't forget to rerun your Cypress tests. Green!
756756
- Commit on Green.
757757

758-
[Code for this section](https://github.com/pairing4good/tdd-amplify-react/commit/8905e6d1e7c40c4ccc912f14bdca83fc19b68b73)
758+
[Code for this section](https://github.com/pairing4good/tdd-amplify-react/commit/8905e6d1e7c40c4ccc912f14bdca83fc19b68b73)
759+
760+
## Usability
761+
Customers rarely ask explicitly for a usable product. In this application rich world that we live in it's assumed that applications will be delivered with common sense usability baked-in. When I look at the application as it stands, a few things pop out at me.
762+
1. Header - there's no heading telling you what this application does
763+
1. Validation - there's no form field validation
764+
1. Reset Form - after a note is created the form fields are not reset
765+
766+
### Header
767+
- Create a new file `Header.js` in the `src` directory
768+
```js
769+
function Header() {
770+
771+
return (
772+
773+
);
774+
}
775+
776+
export
777+
```
778+
- Let's test drive this component
779+
- Create a new file `Header.test.js` in the `src/test` directory
780+
```js
781+
import { render, screen } from '@testing-library/react';
782+
import Header from '../Header';
783+
784+
test('should display header', () => {
785+
render(<Header />);
786+
const heading = screen.getByRole('heading', { level: 1 });
787+
expect(heading).toHaveTextContent('My Notes App')
788+
});
789+
```
790+
- We have a failing test.
791+
- Let's make it pass
792+
```js
793+
function Header() {
794+
795+
return (
796+
<h1>My Notes App</h1>
797+
);
798+
}
799+
800+
export default Header;
801+
```
802+
- It's Green!
803+
- Commit your code!
804+
805+
[Code for this section]()

src/Header.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function Header() {
2+
3+
return (
4+
<h1>My Notes App</h1>
5+
);
6+
}
7+
8+
export default Header;

src/test/Header.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { render, screen } from '@testing-library/react';
2+
import Header from '../Header';
3+
4+
test('should display header', () => {
5+
render(<Header />);
6+
const heading = screen.getByRole('heading', { level: 1 });
7+
expect(heading).toHaveTextContent('My Notes App')
8+
});

0 commit comments

Comments
 (0)