Files
study-bible-project/src/components/reader/MarkNote.test.jsx
T
nmemmertandClaude Sonnet 5.5 207bfcb919
Build and Push Docker Image / build-and-push (push) Successful in 5m13s
Version history, notes on highlights and bookmarks, "you've studied this", prayer journal
- Earlier versions of a study: the server keeps compressed copies (about one per ten minutes of
  editing, the latest 30); Export shows what differs and puts one back (the replaced copy is kept)
- Notes on highlights and bookmarks: synced, merged without loss, in exports and backups
- Reader verse panel lists your studies and chunks that cover the verse, and opens them
- Prayer journal: requests, who for, linked verses, days prayed, answers; synced, in backups
  and the account export; daily prayer reminder through ntfy
- TODO.md lists the ideas not built yet

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-06 10:45:32 -04:00

42 lines
1.9 KiB
React

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { vi, test, expect } from 'vitest';
import MarkNote from './MarkNote.jsx';
test('a note can be added, and is saved trimmed', async () => {
const onSave = vi.fn();
const user = userEvent.setup();
render(<MarkNote note="" onSave={onSave} label="highlight note" />);
await user.click(screen.getByRole('button', { name: /add highlight note/i }));
await user.type(screen.getByLabelText('Your highlight note'), ' Pray this daily ');
await user.click(screen.getByRole('button', { name: 'Save' }));
expect(onSave).toHaveBeenCalledWith('Pray this daily');
});
test('an existing note is shown, and can be edited or cleared', async () => {
const onSave = vi.fn();
const user = userEvent.setup();
render(<MarkNote note="First thought" onSave={onSave} label="note" />);
expect(screen.getByText('First thought')).toBeInTheDocument();
await user.click(screen.getByRole('button', { name: 'Edit note' }));
const box = screen.getByLabelText('Your note');
expect(box).toHaveValue('First thought');
await user.clear(box);
await user.click(screen.getByRole('button', { name: 'Save' })); // an empty note removes it
expect(onSave).toHaveBeenCalledWith('');
});
test('cancelling keeps what was there; Ctrl+Enter saves', async () => {
const onSave = vi.fn();
const user = userEvent.setup();
render(<MarkNote note="Keep me" onSave={onSave} />);
await user.click(screen.getByRole('button', { name: /edit/i }));
await user.type(screen.getByLabelText(/your/i), ' more');
await user.click(screen.getByRole('button', { name: 'Cancel' }));
expect(onSave).not.toHaveBeenCalled();
expect(screen.getByText('Keep me')).toBeInTheDocument();
await user.click(screen.getByRole('button', { name: /edit/i }));
await user.type(screen.getByLabelText(/your/i), ' more{Control>}{Enter}{/Control}');
expect(onSave).toHaveBeenCalledWith('Keep me more');
});