Add unit tests for lib/format.ts
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- testing
Research direction
Start with src/renderer/src/lib/format.ts, which has no dependencies, and read the exported formatCount, formatBytes, relativeTime, hostOf, fileName and fileExtension. Then look at vitest.config.ts and tsconfig.node.json to add the @renderer alias and the path and include entries. Done means pnpm typecheck and pnpm test pass with a new tests/format.test.ts, and format.ts is unchanged.
Written by the indexing model from the issue text.
Description
src/renderer/src/lib/format.ts formats sizes, counts, times, link hosts and file names for the shelf. It has no dependencies, so it's easy to test on its own, but so far only hostOf has tests: two cases in tests/format.test.ts, added with the fix for #13.
The setup is already done. Tests import the file the way the app does, as @renderer/lib/format, and pnpm typecheck covers it.
What to do
Add to tests/format.test.ts:
formatCount:1 file,2 files, a custom plural, a number with a thousands separatorformatBytes: plain bytes, the KB → MB → GB steps, and one decimal under 10 (1.5 KBbut12 KB). Leave out sizes just under the next unit, like1048575bytes: they round to1024 KB, and #29 fixes thatrelativeTime: pass a fixednowso the result doesn't depend on the clock. "Just now", "min ago", "h ago" and "Yesterday" are plain strings. Weekday and date output depend on the machine's locale, so compare those againsttoLocaleDateStringwith the same options instead of hard-coding "Tuesday"hostOf: a normal link,www.stripped, amailto:link, and text that isn't a URL, next to the two%cases already therefileNameandfileExtension: macOS and Windows paths, a dotfile (.envhas no extension), an upper-case extension
Done when
pnpm typecheckandpnpm testpassformat.tsitself is unchanged. If a test turns up another bug, say so in the pull request rather than fixing it in the same one
Suggested pull request title: test: cover the shelf's format helpers
New to OpenPaste? CONTRIBUTING.md covers setup, the code conventions and the checks to run before a pull request (pnpm typecheck, pnpm test, pnpm format, pnpm cleaner). Leave a comment if you're picking this up so nobody doubles up.
Generated by Claude Code
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from alexsilver8/openpaste
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
alexsilver8/openpaste#31 ·
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
alexsilver8/openpaste#32 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
alexsilver8/openpaste#30 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
alexsilver8/openpaste#29 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
alexsilver8/openpaste#27 ·
All issues in alexsilver8/openpaste
Similar issues
-
documentation good first issue hacktoberfest help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
libredb/libredb-studio#1756 ·
Maintainers usually reply within 1 day
-
state:triage-needed
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
lingdojo/kana-dojo#32365 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
friction
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
kentcdodds/kody#3706 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
copperheadhq/copperhead#378 ·
Maintainers usually reply within 1 day