import { describe, expect, it, vi } from 'vitest';
import { triggerHaptic } from './haptics';

describe('triggerHaptic', () => {
  it('uses navigator.vibrate when available', () => {
    const vibrate = vi.fn();
    Object.defineProperty(navigator, 'vibrate', { value: vibrate, configurable: true });

    triggerHaptic();

    expect(vibrate).toHaveBeenCalled();
  });

  it('does nothing when vibrate is unavailable', () => {
    Object.defineProperty(navigator, 'vibrate', { value: undefined, configurable: true });

    expect(() => triggerHaptic('success')).not.toThrow();
  });
});
