tests: add frontend tests

This commit is contained in:
2025-11-11 00:16:03 +03:00
parent e8e26c91e8
commit 3345d4eb94
11 changed files with 1236 additions and 17 deletions

View File

@@ -0,0 +1,43 @@
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: () => {},
}),
});