Update Jest configuration to include TypeScript support and add new code quality checks workflow; translate comments to Russian and adjust paths in test files.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const express = require('express')
|
||||
const mongoose = require('mongoose')
|
||||
const request = require('supertest')
|
||||
const { describe, it, beforeAll, expect } = require('@jest/globals')
|
||||
|
||||
// Mock auth middleware
|
||||
const mockAuthMiddleware = (req, res, next) => {
|
||||
|
||||
@@ -136,6 +136,7 @@ const waitForDatabaseConnection = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line no-undef
|
||||
const connection = await connectDB();
|
||||
if (!connection) {
|
||||
break;
|
||||
@@ -218,6 +219,7 @@ const initializeTestUser = async () => {
|
||||
console.error('Error initializing test data:', error.message);
|
||||
if (error?.code === 13 || /auth/i.test(error?.message || '')) {
|
||||
try {
|
||||
// eslint-disable-next-line no-undef
|
||||
await connectDB();
|
||||
} catch (connectError) {
|
||||
if (process.env.DEV === 'true') {
|
||||
|
||||
@@ -202,6 +202,7 @@ router.get('/docs/:id/file', async (req, res) => {
|
||||
}
|
||||
|
||||
const mimeType = mimeTypes[doc.type] || 'application/octet-stream'
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const sanitizedName = doc.name.replace(/[^\w\s\-\.]/g, '_')
|
||||
|
||||
res.setHeader('Content-Type', mimeType)
|
||||
|
||||
@@ -37,6 +37,7 @@ const storage = multer.diskStorage({
|
||||
const originalExtension = path.extname(fixedName) || '';
|
||||
const baseName = path
|
||||
.basename(fixedName, originalExtension)
|
||||
// eslint-disable-next-line no-control-regex
|
||||
.replace(/[<>:"/\\|?*\x00-\x1F]+/g, '_'); // Убираем только недопустимые символы Windows, оставляем кириллицу
|
||||
cb(null, `${Date.now()}_${baseName}${originalExtension}`);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user