Skip to content

test : exported digest-email helpers and added unit tests#2817

Open
tmdeveloper007 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:pr/2812-digest-email
Open

test : exported digest-email helpers and added unit tests#2817
tmdeveloper007 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:pr/2812-digest-email

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2812.

Summary of What Has Been Done: Created test/digest-email.test.ts with 25 test cases covering esc, pluralise, and langColour. Also exported these helpers from src/lib/digest-email.ts and added a String() coercion to esc to handle non-string inputs safely.

Changes Made:

  • src/lib/digest-email.ts: Added export to esc, pluralise, langColour functions; added String coercion to esc to prevent TypeError on non-string input.
  • test/digest-email.test.ts: 25 test cases covering XSS character escaping, pluralisation logic, language colour lookup.

Impact it Made: esc is a critical XSS sanitiser for the weekly digest email. Making it defensive (coerces non-string to string) prevents crashes and hardens the email template against unexpected input types.

@github-actions github-actions Bot added type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) gssoc26 GSSoC 2026 contribution labels Jun 26, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

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

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for digest-email.ts helpers

1 participant