- 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.
68 lines
1.6 KiB
TypeScript
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();
|
|
});
|
|
});
|
|
});
|