Permalink
Browse files

fix(repository): findPath now returns null when the server doesn't re…

…turn data
  • Loading branch information...
doktordirk committed Aug 31, 2016
1 parent 287b60f commit 63044a07db865ee96b50e7881f116d1ef3b7f1ca
Showing with 17 additions and 1 deletion.
  1. +7 −1 src/repository.js
  2. +10 −0 test/repository.spec.js
@@ -105,8 +105,14 @@ export class Repository {
}
return findQuery
.then(x => this.populateEntities(x))
.then(response => {
return this.populateEntities(response);
})
.then(populated => {
if (!populated) {
return null;
}
if (!Array.isArray(populated)) {
return populated.markClean();
}
@@ -162,6 +162,16 @@ describe('Repository', function() {
done();
});
});
it('Should not fail if no data was returned', function(done) {
let repository = constructRepository('find-test');
repository.getTransport().find = () => Promise.resolve(null);
repository.find()
.then(data => expect(data).toBe(null))
.catch(err => expect(true).toBe(false))
.then(done);
});
});
describe('.count()', function() {

0 comments on commit 63044a0

Please sign in to comment.