title: How to stub node-cache's cache.get()?
body: <p>I'm writing a unit test for a function that uses <code>node-cache</code>. 
  At the following function, </p>
  
  <ol>
  <li>I want to have a string return at the first <code>cache.get</code></li>
  <li>an array in the second <code>cache.get</code></li>
  </ol>
  
  <p>Please note that I removed some parts of code from testFunction since it is not relavant to my question. </p>
  
  <pre><code>const NodeCache          = require('node-cache');
  const cache              = new NodeCache();
  ...
  const testFunction = () =&gt; {
    let myStringCache = cache.get('cacheName1');
    let myArrayCache = cache.get('cacheName2');
  
     ... Do something with caches ...
  
     return 'return something';
  }
  
  ...
  module.exports = {
     ...,
     testFunction,
     ...
  }
  </code></pre>
  
  <p>I created the following test </p>
  
  <pre><code>describe('sample test with testFunction() ', ()=&gt;{
    let stubCache;
    let stub;
    before((done)=&gt;{
      sandbox = sinon.createSandbox();
      stubCache = sandbox.stub(cache, 'get');
      stubCache.withArgs('cacheName1').returns('sample string');
      stubCache.withArgs('cacheName2').returns([1,2,3,4,5,6]);
      stub = proxyquire('./filelocation.js',{
        'node-cache': stubCache
      });
      done();
    });
  
    it('should not throw error',(done)=&gt;{
      chai.expect(stub.testFunction()).not.to.throw;
    });
  })
  </code></pre>
  
  <p>I was Googling around, and there is some partial solution to use <code>proxyquire</code> to stub the value. but looks like it does stub but it's not where I wanted. 
  It stubs at <code>NodeCache</code> but <code>cache</code></p>
  
  <p>So I have questions: </p>
  
  <ol>
  <li>Does anybody know how to stub <code>cache.get()</code> with <code>mocha</code>, <code>chai</code> or <code>sinon</code>? If so, please share how you do it ? </li>
  <li>Is it possible to stub different returns by the argument of <code>cache.get()</code>? </li>
  </ol>