diff --git a/web/src/components/Comment/Comment.test.tsx b/web/src/components/Comment/Comment.test.tsx index a1bc6f833..cf8ba5f66 100644 --- a/web/src/components/Comment/Comment.test.tsx +++ b/web/src/components/Comment/Comment.test.tsx @@ -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() - }).not.toThrow() + const comment = { + name: 'John Doe', + body: 'This is my comment', + createdAt: '2020-01-02T12:34:56Z', + } + render() + + 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) }) })