Files
nobat724_front/lib/routeParams.test.js
T
hamed 9cfbd2e002 feat: Revert homepage changes, fix Persian slug 404, and make various article and about us adjustments
- Removed the newly added city-focused section from the homepage.
- Fixed 404 error for Persian slugs in specialties and blog pages by implementing a decode helper.
- Removed the "مخصوص شهر" label from article headers.
- Linked article tags to their respective filter pages.
- Adjusted related content images to prevent distortion.
- Added a section in the "About Us" page for physician registration guidance.
- Updated the logo in the "About Us" header to the correct version.
- Added tests for the new functionality and ensured existing tests are updated accordingly.
2026-08-08 21:06:48 +03:30

30 lines
1.2 KiB
JavaScript

import { describe, expect, it } from "vitest";
import { decodeRouteParam } from "@/lib/routeParams";
describe("decodeRouteParam", () => {
it("اسلاگ درصدی را به فارسی برمی‌گرداند", () => {
expect(
decodeRouteParam("%D8%AC%D8%B1%D8%A7%D8%AD-%DA%AF%D9%88%D8%A7%D8%B1%D8%B4")
).toBe("جراح-گوارش");
});
it("فارسی خام دست‌نخورده می‌ماند", () => {
expect(decodeRouteParam("جراح-گوارش")).toBe("جراح-گوارش");
});
it("اسلاگ لاتین دست‌نخورده می‌ماند", () => {
expect(decodeRouteParam("gastroenterology")).toBe("gastroenterology");
});
it("درصد ناقص throw نمی‌کند و ورودی را برمی‌گرداند", () => {
// نتیجه‌اش باید ۴۰۴ طبیعی باشد، نه ۵۰۰.
expect(decodeRouteParam("%D8%")).toBe("%D8%");
expect(decodeRouteParam("100%-natural")).toBe("100%-natural");
});
it("ورودی غیر رشته‌ای همان‌طور برمی‌گردد", () => {
expect(decodeRouteParam(undefined)).toBeUndefined();
expect(decodeRouteParam(null)).toBeNull();
});
});