import { afterEach, describe, expect, it, vi } from 'vitest';
import { telegramChannelLink, vkAppLink } from './landing';

describe('telegramChannelLink', () => {
  afterEach(() => vi.unstubAllEnvs());

  it('builds the t.me link from the channel name', () => {
    vi.stubEnv('VITE_TELEGRAM_GAME_CHANNEL_NAME', '@Erudit_Game'); // a leading @ is tolerated
    expect(telegramChannelLink()).toBe('https://telegram.me/Erudit_Game');
  });

  it('returns null when the channel name is unset or blank', () => {
    vi.stubEnv('VITE_TELEGRAM_GAME_CHANNEL_NAME', '   ');
    expect(telegramChannelLink()).toBeNull();
  });
});

describe('vkAppLink', () => {
  afterEach(() => vi.unstubAllEnvs());

  it('returns the configured VK app link verbatim', () => {
    vi.stubEnv('VITE_VK_APP_LINK', 'https://vk.com/app54655464');
    expect(vkAppLink()).toBe('https://vk.com/app54655464');
  });

  it('returns null when the link is unset or blank', () => {
    vi.stubEnv('VITE_VK_APP_LINK', '   ');
    expect(vkAppLink()).toBeNull();
  });
});
