import { afterEach, describe, it, expect, vi } from 'vitest';
import { isGooglePlayBuild, purchasesHidden } from './distribution';

describe('isGooglePlayBuild', () => {
  it('is false by default (no VITE_GP_BUILD flag, not the mock ?gp force)', () => {
    // The unit env is neither the Google Play build nor the mock ?gp force, so the normal purchase
    // actions show. The Google Play stub and the mock force are covered by the Playwright e2e.
    expect(isGooglePlayBuild()).toBe(false);
  });
});

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

  it('is false by default (the build sells normally)', () => {
    expect(purchasesHidden()).toBe(false);
  });

  it('is true for the native MVP that defers billing (VITE_PAYMENTS_DISABLED)', () => {
    vi.stubEnv('VITE_PAYMENTS_DISABLED', '1');
    expect(purchasesHidden()).toBe(true);
  });

  it('is true for the Google Play build (folds isGooglePlayBuild)', () => {
    vi.stubEnv('VITE_GP_BUILD', '1');
    expect(purchasesHidden()).toBe(true);
  });
});
