import { SavesService } from './saves.service';

describe('SavesService', () => {
  it('returns saved false from status when post no longer exists', async () => {
    const savesRepository = {
      findOne: jest.fn(),
    };
    const postsRepository = {
      findById: jest.fn().mockResolvedValue(null),
    };

    const service = new SavesService(
      savesRepository as any,
      postsRepository as any,
      { bumpGlobalVersion: jest.fn() } as any,
      { createSaveNotification: jest.fn() } as any,
    );

    await expect(
      service.getStatus('user-1', { postId: '507f1f77bcf86cd799439011' }),
    ).resolves.toEqual({
      saved: false,
      postId: '507f1f77bcf86cd799439011',
    });
    expect(savesRepository.findOne).not.toHaveBeenCalled();
  });
});
