import { MockDiscord } from '../utils/MockDiscord';

// 예시로 사용할 가상의 Slash Command 핸들러입니다. 향후 실제 Command 객체로 대치될 수 있습니다.
const executePingCommand = async (interaction: any) => {
  await interaction.deferReply();
  const responseText = `Pong! User: ${interaction.user.username}`;
  await interaction.editReply({ content: responseText });
};

describe('Behavior-Driven Test: Ping Command', () => {
  let mockDiscord: MockDiscord;

  beforeEach(() => {
    // 테스트마다 깨끗한 Mock 환경 구성
    mockDiscord = new MockDiscord();
  });

  describe('When the user invokes the /ping command', () => {
    it('Then it should defer the reply and edit it with Pong and the username', async () => {
      // 1. Given (상태 및 Mock Interaction 준비)
      const mockInteraction = mockDiscord.createMockInteraction('ping');

      // 2. When (핸들러 실행)
      await executePingCommand(mockInteraction);

      // 3. Then (결과 추적 및 스펙 충족 확인)
      expect(mockInteraction.deferReply).toHaveBeenCalledTimes(1);
      expect(mockInteraction.editReply).toHaveBeenCalledWith({
        content: 'Pong! User: TestUser',
      });
    });
  });
});
