/**
 * Taro API Mock 文件
 * 通过 jest.config.js 的 moduleNameMapper 重定向 @tarojs/taro 到这里
 */

// 创建所有 Taro API 的 mock 函数
export const mockShowToast = jest.fn()
export const mockShowLoading = jest.fn()
export const mockHideLoading = jest.fn()
export const mockNavigateTo = jest.fn()
export const mockNavigateBack = jest.fn()
export const mockSwitchTab = jest.fn()
export const mockShowModal = jest.fn()
export const mockReLaunch = jest.fn()
export const mockOpenCustomerServiceChat = jest.fn()
export const mockUseRouter = jest.fn()
export const mockRequestPayment = jest.fn()
export const mockGetEnv = jest.fn()
export const mockUseLoad = jest.fn()
export const mockUseShareAppMessage = jest.fn()
export const mockUseShareTimeline = jest.fn()
export const mockGetCurrentInstance = jest.fn()

// 环境类型常量
export const ENV_TYPE = {
  WEAPP: 'WEAPP',
  WEB: 'WEB',
  RN: 'RN',
  SWAN: 'SWAN',
  ALIPAY: 'ALIPAY',
  TT: 'TT',
  QQ: 'QQ',
  JD: 'JD',
  HARMONY: 'HARMONY'
}

// 导出所有 mock 函数，便于在测试中访问
export default {
  // UI 相关
  showToast: mockShowToast,
  showLoading: mockShowLoading,
  hideLoading: mockHideLoading,
  showModal: mockShowModal,

  // 导航相关
  navigateTo: mockNavigateTo,
  navigateBack: mockNavigateBack,
  switchTab: mockSwitchTab,
  reLaunch: mockReLaunch,
  useRouter: () => mockUseRouter(),
  useLoad: (callback: any) => mockUseLoad(callback),

  // 微信相关
  openCustomerServiceChat: mockOpenCustomerServiceChat,
  requestPayment: mockRequestPayment,

  // 系统信息
  getSystemInfoSync: () => ({
    statusBarHeight: 20
  }),
  getMenuButtonBoundingClientRect: () => ({
    width: 87,
    height: 32,
    top: 48,
    right: 314,
    bottom: 80,
    left: 227
  }),
  getEnv: mockGetEnv,

  // 分享相关
  useShareAppMessage: mockUseShareAppMessage,
  useShareTimeline: mockUseShareTimeline,

  // 实例相关
  getCurrentInstance: mockGetCurrentInstance,

  // 环境类型常量
  ENV_TYPE
}

// 为命名导入导出所有函数
export {
  mockShowToast as showToast,
  mockShowLoading as showLoading,
  mockHideLoading as hideLoading,
  mockShowModal as showModal,
  mockNavigateTo as navigateTo,
  mockNavigateBack as navigateBack,
  mockSwitchTab as switchTab,
  mockReLaunch as reLaunch,
  mockUseRouter as useRouter,
  mockUseLoad as useLoad,
  mockOpenCustomerServiceChat as openCustomerServiceChat,
  mockRequestPayment as requestPayment,
  mockGetEnv as getEnv,
  mockUseShareAppMessage as useShareAppMessage,
  mockUseShareTimeline as useShareTimeline,
  mockGetCurrentInstance as getCurrentInstance
}