-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generated as an example of what tests look like so I can learn
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import JournalEntry from './journalEntry'; | ||
|
||
describe('JournalEntry', () => { | ||
let mockEntry; | ||
|
||
beforeEach(() => { | ||
mockEntry = { | ||
creation: new Date().toISOString(), | ||
body: 'This is the body of a test entry' | ||
}; | ||
}); | ||
|
||
it('renders without crashing', () => { | ||
render(<JournalEntry entry={mockEntry} />); | ||
}); | ||
|
||
it('renders the correct date', () => { | ||
const { getByText } = render(<JournalEntry entry={mockEntry} />); | ||
const dateElement = getByText(new Date(mockEntry.creation).toLocaleString()); | ||
|
||
expect(dateElement).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the correct body', () => { | ||
const { getByText } = render(<JournalEntry entry={mockEntry} />); | ||
const bodyElement = getByText('This is the body of a test entry'); | ||
|
||
expect(bodyElement).toBeInTheDocument(); | ||
}); | ||
}); |