Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add unit tests for lib/format.ts

オープン 初心者向け
#12 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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 の本文から書いたものです。

説明

good first issue tests

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 separator
  • formatBytes: plain bytes, the KB → MB → GB steps, and one decimal under 10 (1.5 KB but 12 KB). Leave out sizes just under the next unit, like 1048575 bytes: they round to 1024 KB, and #29 fixes that
  • relativeTime: pass a fixed now so 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 against toLocaleDateString with the same options instead of hard-coding "Tuesday"
  • hostOf: a normal link, www. stripped, a mailto: link, and text that isn't a URL, next to the two % cases already there
  • fileName and fileExtension: macOS and Windows paths, a dotfile (.env has no extension), an upper-case extension
Done when
  • pnpm typecheck and pnpm test pass
  • format.ts itself 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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

alexsilver8/openpaste のほかの issue

alexsilver8/openpaste の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。