-
-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3837d4b
commit db84460
Showing
2 changed files
with
85 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,40 @@ | ||
const mockRssData = { | ||
blog: [ | ||
{ | ||
title: 'Non-Featured Post 1', | ||
slug: '/blog/non-featured-post-1', | ||
excerpt: 'This is a non-featured post', | ||
date: '2023-07-05', | ||
featured: false, | ||
}, | ||
{ | ||
title: 'Test Post 1', | ||
slug: '/blog/test-post-1', | ||
excerpt: 'This is a featured test post', | ||
date: '2023-07-07', | ||
featured: true, | ||
cover: '/img/test-cover.jpg', | ||
}, | ||
{ | ||
title: 'Another Featured Post', | ||
slug: '/blog/another-featured-post', | ||
excerpt: 'This is another featured post', | ||
date: '2023-07-06', | ||
featured: true, | ||
cover: '/img/test-cover.svg', | ||
}, | ||
{ | ||
title: 'Non-Featured Post 2', | ||
slug: '/blog/non-featured-post-2', | ||
excerpt: 'This is another non-featured post', | ||
date: '2023-07-03', | ||
featured: false, | ||
cover: '/img/test-cover.webp', | ||
}, | ||
{ | ||
title: 'Non-Featured Post 3', | ||
slug: '/blog/non-featured-post-3', | ||
excerpt: 'This is yet another non-featured post', | ||
date: '2023-07-04', | ||
featured: false, | ||
cover: '/img/test-cover.png', | ||
}, | ||
{ | ||
title: 'Post with Special Characters: & < > "', | ||
slug: '/blog/special-chars', | ||
excerpt: 'Testing HTML entities & encoding', | ||
date: '2023-07-06T12:00:00Z', | ||
featured: false, | ||
}, | ||
{ | ||
title: 'Post with UTC Date Format', | ||
slug: '/blog/utc-date-format', | ||
excerpt: 'This post uses a UTC date format', | ||
date: 'Wed, 05 Jul 2023 12:00:00 GMT', | ||
featured: false, | ||
}, | ||
], | ||
}; | ||
function createMockPost({ | ||
title, | ||
slug, | ||
excerpt, | ||
date, | ||
featured, | ||
cover, | ||
} = {}, useDefaults = true) { | ||
const post = {}; | ||
|
||
const missingDateMockData = { | ||
blog: [ | ||
{ | ||
title: 'Post without Date', | ||
slug: '/blog/no-date-post', | ||
excerpt: 'This post is missing a date', | ||
featured: false, | ||
}, | ||
{ | ||
title: 'Valid Post', | ||
slug: '/blog/valid-post', | ||
excerpt: 'This post has a valid date', | ||
date: '2024-07-05', | ||
featured: true, | ||
}, | ||
], | ||
}; | ||
if (useDefaults) { | ||
post.title = title ?? 'Default Post Title'; | ||
post.slug = slug ?? '/blog/default-post'; | ||
post.excerpt = excerpt ?? 'This is a default excerpt'; | ||
post.date = date ?? new Date().toISOString(); | ||
post.featured = featured ?? false; | ||
} else { | ||
if (title !== undefined) post.title = title; | ||
if (slug !== undefined) post.slug = slug; | ||
if (excerpt !== undefined) post.excerpt = excerpt; | ||
if (date !== undefined) post.date = date; | ||
if (featured !== undefined) post.featured = featured; | ||
} | ||
|
||
const incompletePostMockData = { | ||
blog: [ | ||
{ | ||
slug: '/blog/incomplete-post', | ||
excerpt: 'This post is incomplete', | ||
date: '2024-07-05', | ||
featured: false, | ||
}, | ||
], | ||
}; | ||
if (cover !== undefined) post.cover = cover; | ||
return post; | ||
} | ||
|
||
const type = 'blog'; | ||
const title = 'Test Blog RSS'; | ||
const desc = 'Test blog RSS feed'; | ||
const outputPath = 'test-output/blog.xml'; | ||
function createMockData({ | ||
blogPosts = [], | ||
} = {}, useDefaults = true) { | ||
return { | ||
blog: blogPosts.map(post => createMockPost(post, useDefaults)), | ||
}; | ||
} | ||
|
||
module.exports = { mockRssData, title, type, desc, outputPath, missingDateMockData, incompletePostMockData }; | ||
module.exports = { | ||
createMockPost, | ||
createMockData, | ||
}; |