Skip to content

Commit 59d1ebb

Browse files
committed
Fix processOptionsValues returning error if null or undefined
1 parent 001201f commit 59d1ebb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: lib/JSONAPISerializer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ module.exports = class JSONAPISerializer {
728728
});
729729
}
730730

731-
return Object.keys(processedOptions).length ? processedOptions : undefined;
731+
return processedOptions && Object.keys(processedOptions).length ? processedOptions : undefined;
732732
}
733733

734734
/**

Diff for: test/unit/JSONAPISerializer.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,15 @@ describe('JSONAPISerializer', function() {
810810
expect(links).to.have.property('self').to.eql('/articles');
811811
done();
812812
});
813+
814+
it('should process options with a function returning null or undefined', function(done) {
815+
const optionsFn = function(extraData) {
816+
return null;
817+
};
818+
const links = Serializer.processOptionsValues({ id: '1' }, { url : '/articles' }, optionsFn, 'extraData');
819+
expect(links).to.be.undefined;
820+
done();
821+
});
813822
});
814823

815824
describe('serialize', function() {

0 commit comments

Comments
 (0)