Skip to content

test : added unit tests for lib/rss module - #7

Open
tmdeveloper007 wants to merge 2 commits into
mainfrom
#8422
Open

tmdeveloper007 wants to merge 2 commits into
mainfrom
#8422

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Owner

Summary of What Has Been Done

Created lib/rss.test.ts with comprehensive unit tests covering:

  • Parses dev.to feed and returns up to 3 articles with correct fields
  • Constructs the correct hashnode feed URL for standard usernames
  • Strips .hashnode.dev suffix before constructing the URL
  • Uses custom domain URL when username contains a dot and is not a standard username
  • Uses direct URL when username starts with https://
  • Returns an empty array on network errors (no throw)
  • Defaults title to 'Untitled' when missing
  • Defaults link to empty string when missing
  • Defaults pubDate to empty string when missing
  • Formats pubDate using toLocaleDateString

Mocked the rss-parser module to provide controlled fixture data without network calls.

Changes Made

  • New file: lib/rss.test.ts

Impact it Made

Adds first unit test coverage for the RSS feed module, ensuring robust feed parsing for both dev.to and hashnode platforms with proper error handling.

Closes #8422.

Note: please assign this PR to the tmdeveloper007 account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant