Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tktcorporation committed Oct 10, 2022
1 parent 3d22080 commit 25b3dd7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions web/src/components/Comment/Comment.test.tsx
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)
})
})

0 comments on commit 25b3dd7

Please sign in to comment.