chore: fix prettier formatting

This commit is contained in:
Kirill
2026-05-20 19:33:13 +05:00
parent faac332138
commit 3177413acd
6 changed files with 127 additions and 145 deletions
+5 -15
View File
@@ -166,9 +166,7 @@ describe('yookassa getPayment', () => {
describe('yookassa buildReceipt', () => {
it('builds receipt with order items', () => {
const result = buildReceipt({
orderItems: [
{ titleSnapshot: 'Test Product', qty: 2, priceCentsSnapshot: 100000 },
],
orderItems: [{ titleSnapshot: 'Test Product', qty: 2, priceCentsSnapshot: 100000 }],
deliveryFeeCents: 0,
userEmail: 'user@test.ru',
})
@@ -187,9 +185,7 @@ describe('yookassa buildReceipt', () => {
it('adds delivery item when deliveryFeeCents > 0', () => {
const result = buildReceipt({
orderItems: [
{ titleSnapshot: 'Item A', qty: 1, priceCentsSnapshot: 50000 },
],
orderItems: [{ titleSnapshot: 'Item A', qty: 1, priceCentsSnapshot: 50000 }],
deliveryFeeCents: 35000,
userEmail: 'user@test.ru',
})
@@ -202,9 +198,7 @@ describe('yookassa buildReceipt', () => {
it('passes through taxSystemCode', () => {
const result = buildReceipt({
orderItems: [
{ titleSnapshot: 'Item', qty: 1, priceCentsSnapshot: 1000 },
],
orderItems: [{ titleSnapshot: 'Item', qty: 1, priceCentsSnapshot: 1000 }],
deliveryFeeCents: 0,
userEmail: 'user@test.ru',
taxSystemCode: 3,
@@ -241,15 +235,11 @@ describe('yookassa validateWebhook', () => {
})
it('throws if missing event', () => {
expect(() => validateWebhook('127.0.0.1', { type: 'notification', object: {} })).toThrow(
'Missing event or object',
)
expect(() => validateWebhook('127.0.0.1', { type: 'notification', object: {} })).toThrow('Missing event or object')
})
it('throws if missing object', () => {
expect(() => validateWebhook('127.0.0.1', { type: 'notification', event: 'x' })).toThrow(
'Missing event or object',
)
expect(() => validateWebhook('127.0.0.1', { type: 'notification', event: 'x' })).toThrow('Missing event or object')
})
it('throws for invalid body type', () => {
+1 -1
View File
@@ -124,7 +124,7 @@ function isYookassaIp(ip) {
}
function isTestMode() {
return (process.env.YOOKASSA_SECRET_KEY?.startsWith('test_')) ?? false
return process.env.YOOKASSA_SECRET_KEY?.startsWith('test_') ?? false
}
export function validateWebhook(ip, body) {
@@ -1,6 +1,6 @@
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import Fastify from 'fastify'
import jwt from '@fastify/jwt'
import Fastify from 'fastify'
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { prisma } from '../../lib/prisma.js'
import { registerUserPaymentRoutes } from '../user-payments.js'
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import Fastify from 'fastify'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { NOTIFICATION_EVENTS } from '../../../../shared/constants/notification-events.js'
const { mockPrisma } = vi.hoisted(() => ({
+4 -12
View File
@@ -3,10 +3,7 @@ import { prisma } from '../lib/prisma.js'
import { createPayment, buildReceipt, getPayment } from '../lib/yookassa.js'
export async function registerUserPaymentRoutes(fastify) {
fastify.post(
'/api/me/orders/:id/pay',
{ preHandler: [fastify.authenticate] },
async (request, reply) => {
fastify.post('/api/me/orders/:id/pay', { preHandler: [fastify.authenticate] }, async (request, reply) => {
const userId = request.user.sub
const userEmail = request.user.email
@@ -93,13 +90,9 @@ export async function registerUserPaymentRoutes(fastify) {
})
return { confirmationUrl: result.confirmationUrl }
},
)
})
fastify.get(
'/api/me/orders/:orderId/payment',
{ preHandler: [fastify.authenticate] },
async (request, reply) => {
fastify.get('/api/me/orders/:orderId/payment', { preHandler: [fastify.authenticate] }, async (request, reply) => {
const userId = request.user.sub
const { orderId } = request.params
@@ -146,6 +139,5 @@ export async function registerUserPaymentRoutes(fastify) {
} catch {
return { status: payment.status, paid: payment.status === 'succeeded' }
}
},
)
})
}
+1 -1
View File
@@ -1,5 +1,5 @@
import { prisma } from '../lib/prisma.js'
import { NOTIFICATION_EVENTS } from '../../../shared/constants/notification-events.js'
import { prisma } from '../lib/prisma.js'
import { validateWebhook } from '../lib/yookassa.js'
export async function registerYookassaWebhookRoute(fastify) {