mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
refactor(bookings): hand the notes and link to the shared lower part as form fields
The booking and transport dialogs each spelled out the notes and the link as four value and change props, and with the saving flag the two calls became one copied block. The shared lower part now takes the form and its setter, as the dialogs hold them, and writes the two fields itself.
This commit is contained in:
@@ -28,10 +28,8 @@ function setup(overrides: Partial<Props> = {}) {
|
||||
linkAndFiles.mockClear();
|
||||
costs.mockClear();
|
||||
const props: Props = {
|
||||
notes: 'Gate B',
|
||||
onNotesChange: vi.fn(),
|
||||
url: 'https://example.com',
|
||||
onUrlChange: vi.fn(),
|
||||
form: { notes: 'Gate B', url: 'https://example.com' },
|
||||
set: vi.fn(),
|
||||
reservationId: 9,
|
||||
tripFiles: [],
|
||||
pendingFiles: [],
|
||||
@@ -61,7 +59,7 @@ describe('BookingNotesFilesCosts', () => {
|
||||
const area = screen.getByPlaceholderText('Additional notes...');
|
||||
expect(area).toHaveValue('Gate B');
|
||||
fireEvent.change(area, { target: { value: 'Gate C' } });
|
||||
expect(props.onNotesChange).toHaveBeenCalledWith('Gate C');
|
||||
expect(props.set).toHaveBeenCalledWith('notes', 'Gate C');
|
||||
});
|
||||
|
||||
it('FE-PLANNER-NOTESFILESCOSTS-002: hands the link, the files and the costs their parts of the booking', () => {
|
||||
@@ -70,7 +68,6 @@ describe('BookingNotesFilesCosts', () => {
|
||||
expect(linkAndFiles).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
url: 'https://example.com',
|
||||
onUrlChange: props.onUrlChange,
|
||||
reservationId: 9,
|
||||
canAttach: true,
|
||||
uploading: false,
|
||||
@@ -80,6 +77,8 @@ describe('BookingNotesFilesCosts', () => {
|
||||
onDetached: props.attach.detachFile,
|
||||
})
|
||||
);
|
||||
linkAndFiles.mock.calls[0][0].onUrlChange('https://example.org');
|
||||
expect(props.set).toHaveBeenCalledWith('url', 'https://example.org');
|
||||
expect(costs).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
reservationId: 9,
|
||||
|
||||
Reference in New Issue
Block a user