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

80% Statements 4/5
75% Branches 3/4
66.67% 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 14 15 16 17 181x                 1x       3x   3x    
import isNullsy from './is-nullsy';
 
/**
 * Verify that obj1 and obj2 have different 'field' field
 * Returns false if either object is null/undefined
 *
 * @param obj1
 * @param obj2
 */
export default function ensureFieldHasChanged (
  obj1: Record<string, unknown>,
  obj2: Record<string, unknown>
): (field: string) => boolean {
  return (isNullsy(obj1) || isNullsy(obj2))
    ? () => false
    : field => obj1[field] !== obj2[field];
}