Add unit tests for the mail text helpers

Đang mở Phù hợp với người mới
#37 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
testing

Hướng nghiên cứu

Đọc packages/mail/src/text.ts và một bài kiểm thử gần đó trong packages/mail/test để làm theo các quy ước của Vitest. Thêm packages/mail/test/text.test.ts với bảy nhóm trường hợp được liệt kê trong issue, giữ nguyên text.ts và chỉ sử dụng địa chỉ hư cấu. Chạy pnpm --filter @hermit/mail test và pnpm --filter @hermit/mail test test/text.test.ts; công việc hoàn tất khi các bài kiểm thử mới chạy thành công và thất bại nếu một kỳ vọng bị cố ý làm sai.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
11
Fork
0
Merge trung bình
10 phút
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DojoCodingLabs/hermit

Tất cả issue của DojoCodingLabs/hermit

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.