Add unit tests for the mail text helpers

Offen Anfängerfreundlich
#37 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Dokumentation
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
testing

Rechercherichtung

Lies packages/mail/src/text.ts und einen benachbarten Test in packages/mail/test, um den Vitest-Konventionen zu folgen. Füge packages/mail/test/text.test.ts mit den sieben im Issue aufgeführten Fallgruppen hinzu, lasse text.ts unverändert und verwende ausschließlich fiktive Adressen. Führe pnpm --filter @hermit/mail test und pnpm --filter @hermit/mail test test/text.test.ts aus; fertig ist die Aufgabe, wenn die neuen Tests bestehen und fehlschlagen, wenn eine Erwartung absichtlich falsch gemacht wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.
Vorherrschende Sprache
TypeScript
Sterne
11
Forks
0
Ø Merge
10 Min.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus DojoCodingLabs/hermit

Alle Issues in DojoCodingLabs/hermit

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.