Chapter 6 - Adding Comments to Schema - Complete

This commit is contained in:
Colin Diem
2022-04-26 01:24:39 -04:00
parent e180c93ada
commit ac15c86840
15 changed files with 307 additions and 11 deletions

View File

@@ -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)
})
})