all files / src/__tests__/ mapValues.spec.js

87.5% Statements 14/16
100% Branches 4/4
75% Functions 6/8
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                          
import expect from 'expect';
import mapValues from '../mapValues';
 
describe('mapValues', () => {
  it('should return undefined when given undefined', () => {
    expect(mapValues(undefined, () => null))
      .toBe(undefined);
  });
 
  it('should return null when given null', () => {
    expect(mapValues(null, () => null))
      .toBe(null);
  });
 
  it('should call a function on each value', () => {
    expect(mapValues({
      a: 1,
      b: 2,
      c: 3,
      d: 4
    }, value => value * 2))
      .toBeA('object')
      .toEqual({
        a: 2,
        b: 4,
        c: 6,
        d: 8
      });
  });
});