[ci] format

This commit is contained in:
bluwy 2023-05-15 06:12:35 +00:00 committed by fredkbot
parent a37e67b520
commit a1bac1d5b6
2 changed files with 14 additions and 11 deletions

View file

@ -2,7 +2,10 @@ import { z } from 'astro/zod';
export const rssSchema = z.object({ export const rssSchema = z.object({
title: z.string(), title: z.string(),
pubDate: z.union([z.string(), z.number(), z.date()]).transform((value) => new Date(value)).refine((value) => !isNaN(value.getTime())), pubDate: z
.union([z.string(), z.number(), z.date()])
.transform((value) => new Date(value))
.refine((value) => !isNaN(value.getTime())),
description: z.string().optional(), description: z.string().optional(),
customData: z.string().optional(), customData: z.string().optional(),
draft: z.boolean().optional(), draft: z.boolean().optional(),

View file

@ -197,15 +197,15 @@ describe('rss', () => {
chai.expect(body).xml.to.equal(validXmlResult); chai.expect(body).xml.to.equal(validXmlResult);
}); });
it('should fail when an invalid date string is provided', async () => { it('should fail when an invalid date string is provided', async () => {
const res = rssSchema.safeParse({ const res = rssSchema.safeParse({
title: phpFeedItem.title, title: phpFeedItem.title,
pubDate: 'invalid date', pubDate: 'invalid date',
description: phpFeedItem.description, description: phpFeedItem.description,
link: phpFeedItem.link, link: phpFeedItem.link,
}) });
chai.expect(res.success).to.be.false; chai.expect(res.success).to.be.false;
chai.expect(res.error.issues[0].path[0]).to.equal('pubDate'); chai.expect(res.error.issues[0].path[0]).to.equal('pubDate');
}); });
}); });