import {
  describe,
  expect,
  it
} from 'vitest';

import {
  buildRemotePushSkipMessage,
  resolveRemotePushSkipReason,
  shouldRegisterForRemotePush,
  type RemotePushRegistrationGateInput
} from './mobile-push-registration.rules';

describe('mobile-push-registration.rules', () => {
  const configuredInput: RemotePushRegistrationGateInput = {
    hasPushPlugin: true,
    hasDevicePlugin: true,
    remotePushConfigured: true
  };

  it('skips registration when remote push is not configured', () => {
    expect(
      shouldRegisterForRemotePush({
        ...configuredInput,
        remotePushConfigured: false
      })
    ).toBe(false);
  });

  it('skips registration when the push plugin is unavailable', () => {
    expect(
      shouldRegisterForRemotePush({
        ...configuredInput,
        hasPushPlugin: false
      })
    ).toBe(false);
  });

  it('skips registration when the device plugin is unavailable', () => {
    expect(
      shouldRegisterForRemotePush({
        ...configuredInput,
        hasDevicePlugin: false
      })
    ).toBe(false);
  });

  it('allows registration when plugins and remote push are available', () => {
    expect(shouldRegisterForRemotePush(configuredInput)).toBe(true);
  });

  it('reports why registration was skipped', () => {
    expect(
      resolveRemotePushSkipReason({
        ...configuredInput,
        remotePushConfigured: false
      })
    ).toBe('remote-push-not-configured');
  });

  it('builds a single actionable skip message for missing Firebase setup', () => {
    expect(buildRemotePushSkipMessage('remote-push-not-configured')).toContain('google-services.json');
  });
});
