Add unit tests for the mail text helpers

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
testing

調査の方向性

packages/mail/src/text.tsとpackages/mail/test内の近くにあるテストを読み、Vitestの規約に従ってください。issueに列挙された7つのケース群を含むpackages/mail/test/text.test.tsを追加し、text.tsは変更せず、架空のアドレスのみを使用してください。pnpm --filter @hermit/mail testとpnpm --filter @hermit/mail test test/text.test.tsを実行してください。新しいテストが成功し、期待値を意図的に壊すと失敗することが完了の条件です。

索引モデルが issue の本文から書いたものです。

説明

agent-friendly good first issue

Why

packages/mail/src/text.ts turns Gmail, Outlook and IMAP message bodies into plain text, and none of its helpers has a test file of its own. ROADMAP.md, Now: mail is part of the everyday loop.

What to do

Create packages/mail/test/text.test.ts (Vitest, like the other files in packages/mail/test) and import from ../src/text.ts. Cover:

  1. base64ToBytes: plain base64, base64url (- and _), and text with padding and line breaks.
  2. utf8Decode and decodeBase64Text: Spanish accents and ñ, a four-byte character, and a broken sequence that becomes U+FFFD.
  3. decodeEntities: named (á, ñ, &), decimal and hex references, and an unknown name left as it is.
  4. htmlToText: script, style, head and title dropped with their contents, comments dropped, a line break at br, p, div, li and headings, and no blank lines left.
  5. plainText: CRLF becomes LF, runs of spaces collapse, and at most one blank line remains in a row.
  6. clip: text at or under the limit unchanged; longer text cut, with "..." and no space before it.
  7. splitAddresses: commas inside quotes and inside angle brackets don't split; an empty or missing header gives an empty list.

Check that each test can fail: break one expectation on purpose, see it fail, put it back.

Done when

  • pnpm --filter @hermit/mail test runs the new file and it passes.
  • packages/mail/src/text.ts is unchanged.

How to check

pnpm --filter @hermit/mail test
pnpm --filter @hermit/mail test test/text.test.ts

Keep in mind

  • Tests only. If a test shows a real bug (for example, clip("hello", 2) returns more than two characters), open a bug report and leave text.ts alone here.
  • Leave oneLine() out. It flattens fields other people control before the model reads them, so its tests get their own issue.
  • Made-up people and example.com addresses only. Never paste a real message.
主要言語
TypeScript
スター
11
フォーク
0
平均マージ
10分
マージ済み PR(30日)
6

環境構築

はじめの一歩

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

DojoCodingLabs/hermit のほかの issue

DojoCodingLabs/hermit の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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