Skip to content

Commit

Permalink
Chat GPT prompted first tests.
Browse files Browse the repository at this point in the history
Generated as an example of what tests look like so I can learn
  • Loading branch information
rossdrew committed Apr 11, 2024
1 parent 5d2d00b commit 873c2cc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions journal-ui/src/components/journalEntry.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { render } from '@testing-library/react';
import JournalEntry from './journalEntry';

describe('JournalEntry', () => {
let mockEntry;

beforeEach(() => {
mockEntry = {
creation: new Date().toISOString(),
body: 'This is the body of a test entry'
};
});

it('renders without crashing', () => {
render(<JournalEntry entry={mockEntry} />);
});

it('renders the correct date', () => {
const { getByText } = render(<JournalEntry entry={mockEntry} />);
const dateElement = getByText(new Date(mockEntry.creation).toLocaleString());

expect(dateElement).toBeInTheDocument();
});

it('renders the correct body', () => {
const { getByText } = render(<JournalEntry entry={mockEntry} />);
const bodyElement = getByText('This is the body of a test entry');

expect(bodyElement).toBeInTheDocument();
});
});

0 comments on commit 873c2cc

Please sign in to comment.