All files / src/helpers ensure-field-has-changed.js

80% Statements 4/5
75% Branches 3/4
66.66% Functions 2/3
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13  1x   1x         3x   3x    
 
const isNullsy = require('./is-nullsy');
 
module.exports = ensureFieldHasChanged;
 
// Verify that obj1 and obj2 have different 'field' field
// Returns false if either object is null/undefined
function ensureFieldHasChanged (obj1, obj2) {
  return isNullsy(obj1) || isNullsy(obj2)
    ? () => false
    : field => obj1[field] !== obj2[field];
}