[ci] format

This commit is contained in:
matthewp 2022-07-13 20:39:29 +00:00 committed by fredkbot
parent cd2dbfedb1
commit fa8ec57f16
2 changed files with 14 additions and 10 deletions

View file

@ -152,9 +152,11 @@ const requiredFields = Object.freeze(['link', 'title']);
// Perform validation to make sure all required fields are passed. // Perform validation to make sure all required fields are passed.
function validate(item: RSSFeedItem) { function validate(item: RSSFeedItem) {
for(const field of requiredFields) { for (const field of requiredFields) {
if(!(field in item)) { if (!(field in item)) {
throw new Error(`@astrojs/rss: Required field [${field}] is missing. RSS cannot be generated without it.`); throw new Error(
`@astrojs/rss: Required field [${field}] is missing. RSS cannot be generated without it.`
);
} }
} }
} }

View file

@ -131,16 +131,18 @@ describe('rss', () => {
title: 'Your Website Title', title: 'Your Website Title',
description: 'Your Website Description', description: 'Your Website Description',
site: 'https://astro-demo', site: 'https://astro-demo',
items: [{ items: [
pubDate: new Date(), {
title: 'Some title', pubDate: new Date(),
slug: 'foo' title: 'Some title',
}] slug: 'foo',
},
],
}); });
chai.expect(false).to.equal(true, 'Should have errored'); chai.expect(false).to.equal(true, 'Should have errored');
} catch(err) { } catch (err) {
chai.expect(err.message).to.contain('Required field [link] is missing'); chai.expect(err.message).to.contain('Required field [link] is missing');
} }
}); });
}) });
}); });