import { expect, afterEach } from 'vitest';
import { cleanup } from '@testing-library/vue';
import '@testing-library/jest-dom/vitest';

// Очистка после каждого теста
afterEach(() => {
  cleanup();
});

// Моки для Telegram WebApp API
global.Telegram = {
  WebApp: {
    initData: 'test_init_data',
    DeviceStorage: {
      getItem: (key, callback) => {
        const value = localStorage.getItem(key);
        callback(null, value);
      },
      setItem: (key, value) => {
        localStorage.setItem(key, value);
      },
      deleteItem: (key) => {
        localStorage.removeItem(key);
      },
    },
  },
};

// Моки для window
Object.defineProperty(window, 'matchMedia', {
  writable: true,
  value: (query) => ({
    matches: false,
    media: query,
    onchange: null,
    addListener: () => {},
    removeListener: () => {},
    addEventListener: () => {},
    removeEventListener: () => {},
    dispatchEvent: () => {},
  }),
});

