Chapter 6 - Adding Comments to Schema - Complete
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { render } from '@redwoodjs/testing/web'
|
||||
import { render, screen } from '@redwoodjs/testing/web'
|
||||
|
||||
import Comment from './Comment'
|
||||
|
||||
@@ -7,8 +7,17 @@ import Comment from './Comment'
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user