Skip to content

feat(assertions): support substrings in includes/isIncludedIn on Strings - #451

Merged
ngarbezza merged 1 commit into
mainfrom
feat/449-substring-inclusion
Oct 28, 2026
Merged

ngarbezza merged 1 commit into
mainfrom
feat/449-substring-inclusion

Conversation

@ngarbezza

Copy link
Copy Markdown
Owner

Closes #449

Qué cambia

includes, doesNotInclude, isIncludedIn e isNotIncludedIn trataban un String como lista de caracteres, así que solo funcionaba la búsqueda de un carácter. Ahora, cuando el contenedor y lo buscado son Strings (y no se pasa un criterio de igualdad custom), verifican inclusión de subcadena con String#includes.

  • Array, Set y Map no cambian.
  • Con criterio de igualdad custom se mantiene la comparación carácter a carácter (el criterio opera sobre elementos).
  • Las cuatro aserciones comparten un helper privado #collectionIncludes.
  • Se actualizaron los ejemplos de JSDoc y el README.

Cambio de comportamiento

assert.that('hello').includes('ell') falla hoy y pasa con este PR. Los usos de un solo carácter siguen igual.

Corrección incidental

El helper usa some() en vez de find(). Con find(), assert.that([0, 1]).includes(0) fallaba en main porque el elemento encontrado (0) es falsy. Lo verifiqué contra main y quedó cubierto con un test de regresión.

Verificación

  • npm test: 507 tests OK (10 nuevos, 4 de ellos fallaban antes de la implementación).
  • npm run lint y node bin/simplicity-guardian.js: OK.

🤖 Generated with Claude Code

includes, doesNotInclude, isIncludedIn and isNotIncludedIn compared a
String character by character, so only single-character searches worked.
When both the collection and the searched object are Strings (and no
custom equality criteria is given) they now check for a substring.

The shared lookup also uses some() instead of find(), which fixes
includes() failing when the matching element is falsy (e.g. 0).

Closes #449
@aviator-app

aviator-app Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@ngarbezza
ngarbezza merged commit db3dedb into main Oct 28, 2026
6 checks passed
@ngarbezza
ngarbezza deleted the feat/449-substring-inclusion branch October 28, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Soportar subcadenas en includes / isIncludedIn / doesNotInclude / isNotIncludedIn sobre strings

1 participant