/**
 * @copyright NHCarrigan
 * @license Naomi's Public License
 * @author Naomi Carrigan
 */

// Set required environment variables for tests
process.env.JWT_SECRET = 'test-secret';
process.env.DISCORD_CLIENT_ID = 'test-client-id';
process.env.DISCORD_CLIENT_SECRET = 'test-client-secret';
process.env.DOMAIN = 'http://localhost:3000';
process.env.API_URL = 'http://localhost:3000/api';
process.env.DATABASE_URL = 'postgresql://test:test@localhost:5432/test';
process.env.BASE_URL = 'http://localhost:4200';
process.env.NODE_ENV = 'test';

// Mock ESM packages to avoid import issues in Jest
jest.mock('jsdom', () => ({
  JSDOM: class {
    window = {
      document: {
        createElement: jest.fn(() => ({})),
      },
    };
  },
}));

jest.mock('marked', () => ({
  marked: jest.fn((input: string) => `<p>${input}</p>`),
}));

jest.mock('dompurify', () => {
  const mockDOMPurify = {
    sanitize: jest.fn((input: string) => input),
    addHook: jest.fn(),
  };
  const createDOMPurify = jest.fn(() => mockDOMPurify);
  return createDOMPurify;
});

jest.mock('@nhcarrigan/logger', () => ({
  Logger: class {
    log = jest.fn().mockResolvedValue(undefined);
    error = jest.fn().mockResolvedValue(undefined);
    metric = jest.fn().mockResolvedValue(undefined);
  },
}));