Files
insforge--insforge/backend/tests/unit/stripe-webhook-routes.test.ts
wehub-resource-sync 3a28426bf4
Lint and Format Check / lint-and-format (push) Failing after 0s
Check Migrations / Check for duplicate migration numbers (push) Failing after 1s
CI Pre-merge Check / CI Pre-merge Check (push) Failing after 2m17s
chore: import upstream snapshot with attribution
2026-07-13 12:23:40 +08:00

27 lines
965 B
TypeScript

import { describe, expect, it } from 'vitest';
import { AppError } from '../../src/utils/errors';
import { ERROR_CODES } from '@insforge/shared-schemas';
import { normalizeStripeWebhookError } from '../../src/api/routes/webhooks/stripe.routes';
describe('normalizeStripeWebhookError', () => {
it('maps Stripe signature verification errors to invalid input app errors', () => {
const error = new Error('Webhook signature verification failed');
error.name = 'StripeSignatureVerificationError';
const normalized = normalizeStripeWebhookError(error);
expect(normalized).toBeInstanceOf(AppError);
expect(normalized).toMatchObject({
message: 'Webhook signature verification failed',
statusCode: 400,
code: ERROR_CODES.INVALID_INPUT,
});
});
it('passes through unrelated errors unchanged', () => {
const error = new Error('Unexpected failure');
expect(normalizeStripeWebhookError(error)).toBe(error);
});
});