Add count and edit commands#8
Open
Sauvage666 wants to merge 2 commits into
Open
Conversation
Adds `node notes.js count` which prints "You have N notes." (with correct singular/plural). Also updates the default help message to include the new command. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds `node notes.js edit <id> <new text>` to update the text of an existing note. Guards against missing ID or empty text (usage hint), unknown IDs (returns null instead of crashing), and updates the help message. Includes two integration tests for the happy path and the not-found case. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
node notes.js count— imprime cuántas notas hay (You have N notes., con singular/plural correcto).node notes.js edit <id> <new text>— actualiza el texto de una nota existente.edit(caso exitoso y ID no encontrado).What changed
notes.js— dos nuevos casos en elswitch:countyedit. El casoeditvalida que se pasen ID y texto antes de llamar al store, y maneja el caso de ID inexistente sin crashear.lib/store.js— nueva funciónedit(id, newText)que busca la nota, devuelvenullsi no existe, actualiza el texto y persiste. Exportada junto al resto.tests/notes.test.js— helperwithCleanStorepara tests de integración con filesystem (setup/teardown limpio). Dos tests nuevos: edición exitosa ynullen ID desconocido.Reviewer notes
edites la única función destore.jsque no es pura (toca el filesystem), de ahí el helper de integración en lugar de un test unitario directo.Number(rest[0])devuelveNaNpara input ausente — la validación!idlo cubre porque!NaN === true.!idtambién rechazaid === 0, que no puede ser un ID válido dado quenextIdarranca en 1.Test plan
npm test5/5 enmainantes de cualquier cambionpm test5/5 en esta rama tras ambos commitsnode notes.js count→You have 0 notes.en store vacíonode notes.js edit 1 nuevo texto→Updated note #1: nuevo textonode notes.js edit 999 x→No note #999 foundnode notes.js edit(sin args) → mensaje de uso🤖 Generated with Claude Code