/**
 * Tests for push notification providers.
 */

import { describe, it, expect, beforeEach } from 'vitest';
import { MockPushProvider } from '../providers/mock.js';

describe('MockPushProvider', () => {
  let provider: MockPushProvider;

  beforeEach(() => {
    provider = new MockPushProvider();
  });

  it('isConfigured returns true', () => {
    expect(provider.isConfigured()).toBe(true);
  });

  it('send records notification', async () => {
    const result = await provider.send({
      deviceToken: 'token-123',
      platform: 'ios',
      title: 'Test',
      body: 'Hello',
    });
    expect(result.success).toBe(true);
    expect(result.messageId).toBeDefined();
    expect(provider.sent).toHaveLength(1);
    expect(provider.sent[0]!.title).toBe('Test');
  });

  it('sendBatch records all notifications', async () => {
    const results = await provider.sendBatch([
      { deviceToken: 't1', platform: 'ios', title: 'A', body: 'a' },
      { deviceToken: 't2', platform: 'android', title: 'B', body: 'b' },
    ]);
    expect(results).toHaveLength(2);
    expect(results.every(r => r.success)).toBe(true);
    expect(provider.sent).toHaveLength(2);
  });

  it('reset clears sent history', async () => {
    await provider.send({ deviceToken: 't', platform: 'web', title: 'X', body: 'x' });
    provider.reset();
    expect(provider.sent).toHaveLength(0);
  });
});
