Add unit tests for lib/format.ts
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- testing
Hướng nghiên cứu
Bắt đầu từ src/renderer/src/lib/format.ts, file này không có phụ thuộc, và đọc các hàm được export formatCount, formatBytes, relativeTime, hostOf, fileName và fileExtension. Sau đó xem vitest.config.ts và tsconfig.node.json để thêm alias @renderer cùng các mục path và include. Hoàn thành khi pnpm typecheck và pnpm test đều chạy đạt với một tests/format.test.ts mới và format.ts không bị thay đổi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 0
- Fork
- 3
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của alexsilver8/openpaste
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
alexsilver8/openpaste#31 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
alexsilver8/openpaste#32 ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
alexsilver8/openpaste#30 ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
alexsilver8/openpaste#29 ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
alexsilver8/openpaste#27 ·
Tất cả issue của alexsilver8/openpaste
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
polarsource/polar#15580 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accepted bug via-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
pingdotgg/t3code#20931 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug/1-unconfirmed kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ranxianglei/billion-context#3583 ·
Maintainer thường phản hồi trong vòng 1 ngày