// 测试工具函数
import { render, type RenderResult } from '@testing-library/react'

export const renderTaroComponent = (component: React.ReactElement, options?: any): RenderResult => {
  return render(component, options)
}

// 其他通用的测试工具函数可以在这里添加
export const waitForUpdate = async (timeout = 100) => {
  await new Promise(resolve => setTimeout(resolve, timeout))
}

export const mockConsole = {
  error: jest.spyOn(console, 'error').mockImplementation(() => {}),
  warn: jest.spyOn(console, 'warn').mockImplementation(() => {}),
  log: jest.spyOn(console, 'log').mockImplementation(() => {}),
  info: jest.spyOn(console, 'info').mockImplementation(() => {}),
  debug: jest.spyOn(console, 'debug').mockImplementation(() => {})
}

export const restoreConsole = () => {
  jest.restoreAllMocks()
}