import { renderHook } from '@testing-library/react';
import { useAd } from '../useAd';

// Mock Taro
jest.mock('@tarojs/taro', () => ({
  createRewardedVideoAd: jest.fn(() => ({
    onLoad: jest.fn(),
    onClose: jest.fn(),
    onError: jest.fn(),
    show: jest.fn(),
    load: jest.fn(),
  })),
}));

describe('useAd', () => {
  it('should provide showAd function', () => {
    const { result } = renderHook(() => useAd());
    expect(result.current.showAd).toBeDefined();
    expect(typeof result.current.showAd).toBe('function');
  });

  it('should provide loadAd function', () => {
    const { result } = renderHook(() => useAd());
    expect(result.current.loadAd).toBeDefined();
    expect(typeof result.current.loadAd).toBe('function');
  });

  it('should provide loading state', () => {
    const { result } = renderHook(() => useAd());
    expect(result.current.loading).toBeDefined();
    expect(typeof result.current.loading).toBe('boolean');
  });
});