Skip to content

Commit

Permalink
return null for undefined relationships
Browse files Browse the repository at this point in the history
closes #38
  • Loading branch information
danivek committed Dec 8, 2017
1 parent 0145b0e commit 060fc40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/JSONAPISerializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ module.exports = class JSONAPISerializer {
serializeRelationship(rType, rData, rOptions, included, extraData) {
// No relationship data
if (rData === undefined) {
return undefined;
return null;
}

// Empty relationship data
Expand Down
4 changes: 2 additions & 2 deletions test/unit/JSONAPISerializer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ describe('JSONAPISerializer', function() {
},
});

it('should return undefined for an undefined relationship data', function(done) {
it('should return null for an undefined relationship data', function(done) {
const serializedRelationshipData = Serializer.serializeRelationship('articles', undefined);
expect(serializedRelationshipData).to.eql(undefined);
expect(serializedRelationshipData).to.eql(null);
done();
});

Expand Down

0 comments on commit 060fc40

Please sign in to comment.