Add unit tests for the mail text helpers

未关闭 适合新手
#37 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
testing

调研方向

阅读packages/mail/src/text.ts和packages/mail/test中的一个相邻测试,以遵循Vitest的惯例。添加packages/mail/test/text.test.ts,包含issue中列出的七组案例,保持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 分钟
30 天内合并 PR
6

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DojoCodingLabs/hermit 的其他 Issue

查看 DojoCodingLabs/hermit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。