Repository navigation
feat(assertions): support substrings in includes/isIncludedIn on Strings - #451
Merged
Merged
Conversation
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
Current Aviator status
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #449
Qué cambia
includes,doesNotInclude,isIncludedIneisNotIncludedIntrataban 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 conString#includes.#collectionIncludes.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 defind(). Confind(),assert.that([0, 1]).includes(0)fallaba enmainporque el elemento encontrado (0) es falsy. Lo verifiqué contramainy 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 lintynode bin/simplicity-guardian.js: OK.🤖 Generated with Claude Code