Skip to content

Commit

Permalink
Merge pull request #822 from lrowe/onmissing-nre
Browse files Browse the repository at this point in the history
Fix onMissing null reference error
  • Loading branch information
lrowe committed Nov 30, 2016
2 parents ca841a9 + 5c80bab commit ce46c18
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/get/onMissing.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ function concatAndInsertMissing(model, remainingPath, depth, requestedPath,
}

function isEmptyAtom(atom) {
var type = typeof atom;
if (type !== "object") {
if (atom === null || typeof atom !== "object") {
return false;
}

Expand Down
24 changes: 24 additions & 0 deletions test/falcor/get/get.dataSource-only.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,30 @@ describe('DataSource Only', function() {
}).
subscribe(noOp, done, done);
});
it('should get a directly referenced value from falcor.', function(done) {
var cache = {
reference: {
$type: "ref",
value: ["foo", "bar"]
},
foo: {
bar: {
$type: "atom",
value: "value"
}
}
};
var model = new Model({source: new LocalDataSource(cache)});
var onNext = sinon.spy();
toObservable(model.
get(['reference', null])).
doAction(onNext, noOp, function() {
expect(strip(onNext.getCall(0).args[0])).to.deep.equals({
json: {reference: "value"}
});
}).
subscribe(noOp, done, done);
});
});
describe('_toJSONG', function() {
it('should get a value from falcor.', function(done) {
Expand Down
9 changes: 9 additions & 0 deletions test/get-core/missing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ describe('Missing', function() {
}
});
});
it('should report a missing path ending with null', function() {
getCoreRunner({
input: [['refMissing', null]],
output: { },
requestedMissingPaths: [['refMissing', null]],
optimizedMissingPaths: [['refMissing', null]],
cache: { }
});
});

});

0 comments on commit ce46c18

Please sign in to comment.