Add unit tests for lib/format.ts
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 85/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- testing
調査の方向性
src/renderer/src/lib/format.ts から始めてください。このファイルは依存関係がありません。エクスポートされている formatCount、formatBytes、relativeTime、hostOf、fileName、fileExtension を読んでください。次に vitest.config.ts と tsconfig.node.json を見て、@renderer エイリアスと path、include のエントリを追加してください。新しい tests/format.test.ts を追加して pnpm typecheck と pnpm test が通り、format.ts が変更されていなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 0
- フォーク
- 3
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
alexsilver8/openpaste のほかの issue
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
alexsilver8/openpaste#31 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
alexsilver8/openpaste#32 ·
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
alexsilver8/openpaste#30 ·
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
alexsilver8/openpaste#29 ·
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
alexsilver8/openpaste#27 ·
alexsilver8/openpaste の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
TomerAberbach/profiler-md#733 ·
メンテナーはふだん 1 日以内に返信
-
bug priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
brentspine/brents-toasts#143 ·
-
🐛 bug 🗺️ DB Models & Ops
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
LibreChat-AI/LibreChat#17214 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
Wavvon/Wavvon-clients#136 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
umami-software/umami#4637 ·
メンテナーはふだん 3 日以内に返信