import { vi, describe, it, expect, beforeEach } from 'vitest';
import { InMemoryGameRepository } from './InMemoryGameRepository';
import type { Logger } from '@core/shared/application';

describe('InMemoryGameRepository', () => {
  let repository: InMemoryGameRepository;
  let mockLogger: Logger;

  beforeEach(() => {
    mockLogger = {
      debug: vi.fn(),
      info: vi.fn(),
      warn: vi.fn(),
      error: vi.fn(),
    };
    repository = new InMemoryGameRepository(mockLogger);
  });

  describe('constructor', () => {
    it('should initialize with a logger', () => {
      expect(repository).toBeDefined();
      expect(mockLogger.info).toHaveBeenCalledWith('InMemoryGameRepository initialized.');
    });
  });

  describe('findById', () => {
    it('should return null if game not found', async () => {
      const result = await repository.findById('nonexistent');
      expect(result).toBeNull();
      expect(mockLogger.debug).toHaveBeenCalledWith('[InMemoryGameRepository] Finding game by ID: nonexistent');
      expect(mockLogger.warn).toHaveBeenCalledWith('Game with ID nonexistent not found.');
    });
  });

  describe('findAll', () => {
    it('should return an empty array', async () => {
      const result = await repository.findAll();
      expect(result).toEqual([]);
      expect(mockLogger.debug).toHaveBeenCalledWith('[InMemoryGameRepository] Finding all games.');
    });
  });
});