const { spawnSync } = require('child_process');

describe('Bot Startup', () => {
  test('exits with code 1 if DISCORD_TOKEN is missing', () => {
    // Clear DISCORD_TOKEN
    const env = { ...process.env };
    delete env.DISCORD_TOKEN;

    const result = spawnSync('node', ['src/index.js'], { env, encoding: 'utf-8' });
    expect(result.status).toBe(1);
    expect(result.stderr || result.stdout).toMatch(/DISCORD_TOKEN is missing/);
  });
});
