Add unit tests for the mail text helpers

Abierto Apto para principiantes
#37 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
88/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
testing

Línea de trabajo

Lee packages/mail/src/text.ts y una prueba cercana en packages/mail/test para seguir las convenciones de Vitest. Añade packages/mail/test/text.test.ts con los siete grupos de casos enumerados en la issue, deja text.ts sin cambios y usa únicamente direcciones ficticias. Ejecuta pnpm --filter @hermit/mail test y pnpm --filter @hermit/mail test test/text.test.ts; el trabajo estará terminado cuando las nuevas pruebas pasen y fallen si se rompe deliberadamente una expectativa.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
TypeScript
Estrellas
11
Forks
0
Merge medio
10 min
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DojoCodingLabs/hermit

Todos los issues de DojoCodingLabs/hermit

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.