Add unit tests for lib/format.ts
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- testing
Direzione di ricerca
Inizia da src/renderer/src/lib/format.ts, che non ha dipendenze, e leggi le funzioni esportate formatCount, formatBytes, relativeTime, hostOf, fileName e fileExtension. Poi guarda vitest.config.ts e tsconfig.node.json per aggiungere l'alias @renderer e le voci path e include. Il lavoro è completato quando pnpm typecheck e pnpm test passano con un nuovo tests/format.test.ts e format.ts è invariato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 0
- Fork
- 3
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di alexsilver8/openpaste
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
alexsilver8/openpaste#31 ·
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
alexsilver8/openpaste#32 ·
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
alexsilver8/openpaste#30 ·
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
alexsilver8/openpaste#29 ·
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
alexsilver8/openpaste#27 ·
Tutte le issue di alexsilver8/openpaste
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
juice-shop/juice-shop#3686 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dsh-market/dsh-market#877 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
ScottKirvan/GOMAC#61 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
stellar/stellar-dev-skill#151 ·
I maintainer di solito rispondono entro 1 giorno