Files
canina/frontend/application/app/blog/rss.xml/route.test.ts
T
devops 159e4a4cbf
Deploy Canina / deploy (push) Successful in 2m47s
fix(blog): separate Canina author and editorial team
2026-10-20 07:52:07 +00:00

5 lines
1.1 KiB
TypeScript

import { afterEach,describe,expect,it,vi } from "vitest";
import { GET } from "./route";
afterEach(()=>{vi.unstubAllGlobals();vi.unstubAllEnvs()});
describe("blog RSS dates",()=>{it("keeps pubDate immutable and derives lastBuildDate from real valid dates",async()=>{vi.stubEnv("NEXT_PUBLIC_SITE_URL","https://canina.ir");vi.stubGlobal("fetch",vi.fn().mockResolvedValue({ok:true,json:async()=>({data:[{slug:"a",title:"A",status:"PUBLISHED",publishedAt:"2026-01-01T00:00:00Z",contentUpdatedAt:"2026-01-03T00:00:00Z",updatedAt:"2026-01-04T00:00:00Z"}]})}));const xml=await (await GET()).text();expect(xml).toContain(`<pubDate>${new Date("2026-01-01T00:00:00Z").toUTCString()}</pubDate>`);expect(xml).toContain(`<lastBuildDate>${new Date("2026-01-03T00:00:00Z").toUTCString()}</lastBuildDate>`);});it("uses the stable fallback author for authorless posts",async()=>{vi.stubGlobal("fetch",vi.fn().mockResolvedValue({ok:true,json:async()=>({data:[{slug:"a",title:"A",status:"PUBLISHED",publishedAt:"2026-01-01T00:00:00Z",author:{firstName:"",lastName:""}}]})}));const xml=await (await GET()).text();expect(xml).toContain("<author>کنینا</author>");});});