Skip to content

Commit 082a161

Browse files
committed
Added one additional test to cover both self and related links being null
1 parent 9ce1bf0 commit 082a161

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/serializer.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,6 +2662,33 @@ describe('JSON API Serializer', function () {
26622662
expect(json.data.relationships.address).eql({ data: null });
26632663
});
26642664

2665+
it('should not be set when the self and related relationshipLinks return null', function () {
2666+
var dataSet = {
2667+
id: '54735750e16638ba1eee59cb',
2668+
firstName: 'Sandro',
2669+
lastName: 'Munda',
2670+
address: null,
2671+
};
2672+
2673+
var json = new JSONAPISerializer('users', {
2674+
attributes: ['firstName', 'lastName', 'address'],
2675+
address: {
2676+
ref: 'id',
2677+
included: false,
2678+
relationshipLinks: {
2679+
self: function () {
2680+
return null;
2681+
},
2682+
related: function(){
2683+
return null;
2684+
}
2685+
},
2686+
}
2687+
}).serialize(dataSet);
2688+
2689+
expect(json.data.relationships.address).eql({ data: null });
2690+
});
2691+
26652692
it('should be set when the relationshipLinks returns a self link only', function () {
26662693
var dataSet = {
26672694
id: '54735750e16638ba1eee59cb',

0 commit comments

Comments
 (0)