Fix test/include.test.js
- Vorherrschende Sprache
- JavaScript
- Sterne
- 2k
- Forks
- 238
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, nodejs
- Bereich
- testing
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 55/100