Fix test/include.test.js
- Lenguaje dominante
- JavaScript
- Estrellas
- 2k
- Forks
- 238
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
In my pull request for jugglindb-redis (see https://github.com/jugglingdb/redis-adapter/pull/3), I noticed that the include.test.js is not properly testing the cached relations for included models.
For example:
``` javascript
u.__cachedRelations.should.have.property('posts');
u.__cachedRelations.posts.forEach(function(p) {
p.userId.should.equal(u.id);
});
```
`p.userId.should.equal(u.id)` will never be checked if `u.__cachedRelations.posts == []`, thus the test will pass. Without comparing the query results to the mocked models, the tests can't check if the cached relations _should_ contain results.
I will submit a pull request when I find time, but I thought I should point it out, as many adapters could be erroneously passing the include tests.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
The issue is about test/include.test.js. First, examine that file to understand the structure of the cached relations tests. Look at the specific test block for included models and the mocking setup. The fix involves ensuring the test validates cached relations even when the array is empty, possibly by comparing query results to mocked models. Run the existing tests to see current behavior, then modify the test logic to properly assert the expected conditions.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, nodejs
- Área
- testing
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 55/100