-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3d22080
commit 25b3dd7
Showing
1 changed file
with
14 additions
and
7 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 |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import { render } from '@redwoodjs/testing/web' | ||
import { render, screen } from '@redwoodjs/testing' | ||
|
||
import Comment from './Comment' | ||
|
||
// Improve this test with help from the Redwood Testing Doc: | ||
// https://redwoodjs.com/docs/testing#testing-components | ||
|
||
describe('Comment', () => { | ||
it('renders successfully', () => { | ||
expect(() => { | ||
render(<Comment />) | ||
}).not.toThrow() | ||
const comment = { | ||
name: 'John Doe', | ||
body: 'This is my comment', | ||
createdAt: '2020-01-02T12:34:56Z', | ||
} | ||
render(<Comment comment={comment} />) | ||
|
||
expect(screen.getByText(comment.name)).toBeInTheDocument() | ||
expect(screen.getByText(comment.body)).toBeInTheDocument() | ||
const dateExpect = screen.getByText('2 January 2020') | ||
expect(dateExpect).toBeInTheDocument() | ||
expect(dateExpect.nodeName).toEqual('TIME') | ||
expect(dateExpect).toHaveAttribute('datetime', comment.createdAt) | ||
}) | ||
}) |