Welcome to mirror list, hosted at ThFree Co, Russian Federation.

obj_spec.js « utils « test_helpers « frontend_integration « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ad7b4a1a4cff04fa4794ad05467f3b77f46a22c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { withKeys, withValues } from './obj';

describe('frontend_integration/test_helpers/utils/obj', () => {
  describe('withKeys', () => {
    it('picks and maps keys', () => {
      expect(withKeys({ a: '123', b: 456, c: 'd' }, { b: 'lorem', c: 'ipsum', z: 'zed ' })).toEqual(
        { lorem: 456, ipsum: 'd' },
      );
    });
  });

  describe('withValues', () => {
    it('sets values', () => {
      expect(withValues({ a: '123', b: 456 }, { b: 789 })).toEqual({ a: '123', b: 789 });
    });

    it('throws if values has non-existent key', () => {
      expect(() => withValues({ a: '123', b: 456 }, { b: 789, bogus: 'throws' })).toThrow(
        `[mock_server] Cannot write property that does not exist on object 'bogus'`,
      );
    });
  });
});