Пример #1
0
    it('should returns new function with cached arguments', () => {
      var spy1 = jasmine.createSpyObj('spy', ['test1', 'test2', 'test3', 'test4']);

      spy1.test1.and.callFake((a, b, c) => (a + b) + c);

      var partialized = partial(spy1.test1, 1, 2);

      expect(partialized('foo')).toBe('3foo');

      partialized = partial(spy1.test1);

      expect(partialized(1, 2, 'foo')).toBe('3foo');

      partialized = partial(spy1.test1, 1, 2, 3);

      expect(partialized('foo')).toBe(6);
    });
Пример #2
0
    it('should returns new function with cached arguments', () => {
      const spyObject = {
        test1: (a, b, c) => (a + b) + c,
      };
      const spyTest1 = jest.spyOn(spyObject, 'test1');
      let partialized = partial(spyTest1, 1, 2);

      expect(partialized('foo')).toBe('3foo');

      partialized = partial(spyTest1);

      expect(partialized(1, 2, 'foo')).toBe('3foo');

      partialized = partial(spyTest1, 1, 2, 3);

      expect(partialized('foo')).toBe(6);
    });