title: How do I test call and apply functions in jest?
body: <p>Here's my <em>callnapply.js</em> file</p>
  
  <pre><code>const callAndApply = {
    caller(object, method, nameArg, ageArg, tShirtSizeArg) {
      method.call(object, nameArg, ageArg, tShirtSizeArg);
    },
    applier(object, method, argumentsArr) {
      method.apply(object, argumentsArr);
    },
  };
  module.exports = callAndApply;
  </code></pre>
  
  <p>And here's a snippet from the test file which contains the non-working test:</p>
  
  <pre><code>const callnapply = require('./callnapply');
  
  test('testing Function.prototype.call as mock function', () =&gt; {
      const outer = jest.fn(); 
      const name = 'Aakash';
      const age = 22;
      const tee = 'M';
      callnapply.caller(this, outer, name, age, tee);
      expect(outer.call).toHaveBeenCalledWith(name, age, tee);
  });
  </code></pre>
  
  <p>How do I write the test to check if the <code>method</code> that I am passing is, in fact, being called by the <code>Function.prototype.call</code> function only? I want to check whether <code>.call()</code> is being called and not some other implementation that has been written for the <code>method</code> call.</p>