mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 06:26:26 +00:00
b71e32cf12
The unused day pills go, a client-only type stops being exported, the place form context moves out of the page hook so its view model stays the first object it returns, the place form test helpers split the stub component from the plain setup, and four router files are formatted.
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
// FE-PLANNER-PLACEFORM-125: the place form of a tour (TIME-02)
|
|
import type { TourListItem } from '@trek/shared';
|
|
|
|
import { buildAssignment, buildPlace } from '../../../tests/helpers/factories';
|
|
import { placeFormProps, seedPlaceFormStores } from '../../../tests/helpers/placeFormSetup';
|
|
import { render, screen } from '../../../tests/helpers/render';
|
|
import { resetAllStores } from '../../../tests/helpers/store';
|
|
import PlaceFormModal from './PlaceFormModal';
|
|
|
|
// CustomTimePicker as a plain text input, see TimePickerStub.
|
|
vi.mock('../shared/CustomTimePicker', async () => ({
|
|
default: (await import('../../../tests/helpers/placeForm')).TimePickerStub,
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
resetAllStores();
|
|
seedPlaceFormStores();
|
|
});
|
|
|
|
describe('PlaceFormModal for a tour', () => {
|
|
it('FE-PLANNER-PLACEFORM-125: a tour with a start and no end says below its times the end it works out to (TIME-02)', () => {
|
|
const place = buildPlace({ id: 7, name: 'Ridge', place_time: '09:00', end_time: null });
|
|
const assignment = buildAssignment({ id: 42, day_id: 3, place });
|
|
const tour: TourListItem = {
|
|
place_id: 7,
|
|
name: 'Ridge',
|
|
tour_type: 'hike',
|
|
distance: 8,
|
|
elevation_gain: 300,
|
|
elevation_loss: 300,
|
|
duration: 150,
|
|
planned_duration_minutes: null,
|
|
break_additional_minutes: 30,
|
|
difficulty: null,
|
|
wanderer_ref: null,
|
|
match_confidence: 1,
|
|
max_hiking_difficulty: 2,
|
|
planned: true,
|
|
caution: false,
|
|
};
|
|
const { unmount } = render(
|
|
<PlaceFormModal {...placeFormProps} place={place} assignmentId={42} dayAssignments={[assignment]} tour={tour} />
|
|
);
|
|
expect(screen.getByTestId('tour-day-end-hint')).toHaveTextContent(
|
|
'Left empty, the end is worked out: 12:00, the start plus the tour time of 3 h.'
|
|
);
|
|
unmount();
|
|
render(<PlaceFormModal {...placeFormProps} place={place} assignmentId={42} dayAssignments={[assignment]} />);
|
|
expect(screen.queryByTestId('tour-day-end-hint')).not.toBeInTheDocument();
|
|
});
|
|
});
|