Files
canina/backend/src/common/interceptors/decimal.interceptor.spec.ts
T
devops ddbf1ca026
Deploy Canina / deploy (push) Successful in 4m1s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 7s
test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation.
- Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings.
- Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors.
- Fixed unmount lifecycle guards, promise error handling, and component edge cases.
2026-10-13 16:01:00 +00:00

68 lines
1.6 KiB
TypeScript

import { DecimalInterceptor } from "./decimal.interceptor";
import { ExecutionContext, CallHandler } from "@nestjs/common";
import { Prisma } from "@prisma/client";
import { of } from "rxjs";
describe("DecimalInterceptor", () => {
let interceptor: DecimalInterceptor;
beforeEach(() => {
interceptor = new DecimalInterceptor();
});
it("should be defined", () => {
expect(interceptor).toBeDefined();
});
it("should transform Prisma.Decimal instances to exact string representations", (done) => {
const mockData = {
id: "order-1",
totalAmount: new Prisma.Decimal("64.98"),
items: [
{
id: "item-1",
unitPrice: new Prisma.Decimal("32.49"),
},
],
};
const executionContext = {} as ExecutionContext;
const callHandler: CallHandler = {
handle: () => of(mockData),
};
interceptor.intercept(executionContext, callHandler).subscribe((result) => {
expect(result).toEqual({
id: "order-1",
totalAmount: "64.98",
items: [
{
id: "item-1",
unitPrice: "32.49",
},
],
});
done();
});
});
it("should leave non-decimal values unchanged", (done) => {
const mockData = {
name: "Test",
age: 5,
isActive: true,
createdAt: new Date("2026-01-01T00:00:00.000Z"),
};
const executionContext = {} as ExecutionContext;
const callHandler: CallHandler = {
handle: () => of(mockData),
};
interceptor.intercept(executionContext, callHandler).subscribe((result) => {
expect(result).toEqual(mockData);
done();
});
});
});