import { TripPreferenceOverridesService } from './trip-preference-overrides.service';

describe('TripPreferenceOverridesService', () => {
  it('forwards the subject and overrides to the repository', async () => {
    const created = {
      id: 'o1',
      tripId: 't1',
      userId: 'u1',
      travelerId: null,
      overrides: { preferredPace: 'fast' },
    };
    const repository = { upsert: jest.fn().mockResolvedValue(created) };
    const service = new TripPreferenceOverridesService(repository as never);

    const subject = { type: 'USER' as const, userId: 'u1' };
    await expect(
      service.upsertOverride('t1', subject, { preferredPace: 'fast' }),
    ).resolves.toEqual(created);
    expect(repository.upsert).toHaveBeenCalledWith('t1', subject, {
      preferredPace: 'fast',
    });
  });
});
