Skip to content

test : added unit tests for dateUtils.ts functions#784

Open
tmdeveloper007 wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#764
Open

test : added unit tests for dateUtils.ts functions#784
tmdeveloper007 wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#764

Conversation

@tmdeveloper007
Copy link
Copy Markdown
Contributor

Closes #764.

Summary of What Has Been Done:
Added test/dateUtils.test.ts with comprehensive vitest unit tests covering all exported functions in src/lib/dateUtils.ts.

Changes Made:
New file: test/dateUtils.test.ts

Test coverage (10 tests):

  • toDateStr: formats date as YYYY-MM-DD with zero-padding
  • getThisWeekRange: start before end, Monday 00:00:00 UTC, end at 23:59:59
  • getLastWeekRange: returns previous week, handles month boundary

Uses vi.useFakeTimers() and vi.setSystemTime() for deterministic time-dependent testing.

Impact it Made:
All 10 tests pass. Week-boundary calculations are now validated across month transitions.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

@TESTPERSONAL is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts) labels May 23, 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

Closes Priyanshu-byte-coder#776

Added test/getRedisClient.test.ts covering:
- Returns null when UPSTASH_REDIS_REST_URL is not set
- Returns null when UPSTASH_REDIS_REST_TOKEN is not set
- Returns Redis instance when both env vars are set
- Returns same singleton instance on repeated calls (cache behavior)

Impact: All 4 tests pass. Redis client lazy initialization validated.
Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import pattern is correct — function imported from source. Three infrastructure issues to fix before merge:

  1. Missing "test": "vitest run" in package.json scripts — tests can't run in CI without this.
  2. vitest.config.ts missing resolve.alias@/lib/* path aliases fail without:
import path from 'path'
export default defineConfig({
  resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
  test: { globals: true }
})
  1. Missing EOF newline on test file.

@Priyanshu-byte-coder Priyanshu-byte-coder added gssoc:approved GSSoC: PR approved for scoring level:beginner GSSoC: Beginner difficulty (20 pts) labels May 23, 2026
@tmdeveloper007 tmdeveloper007 force-pushed the #764 branch 5 times, most recently from 7825f43 to 488132a Compare May 23, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:beginner GSSoC: Beginner difficulty (20 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 dateUtils.ts functions

2 participants