title: NodeJs test case for code in side forEach method of array
body: <p>here files is a array like var files = ['/tmp/1.pdf', '/tmp/2.pdf'];</p>
  
  <p>Method:</p>
  
  <pre><code>var createAttachmentsForMail = function (files) {
      var attachmets = [];
  
      files.forEach(function (value) {
          attachmets.push(
              {
                  "Content-type": mime.lookup(value),
                  "FileName": path.basename(value),
                  "content": new   Buffer(fs.readFileSync(value)).toString('base64')
              }
          );
      });
  
      return attachmets;
  };
  </code></pre>
  
  <p>Test method: <strong>I want to test that attachment.push is called 2 times but how? I also want to assert what attachments are return.</strong></p>
  
  <pre><code>describe("Create attachments", function() {
  
      it('from pdf path', function() {
  
          var files = [
              '/tmp/1.pdf',
              '/tmp/2.pdf'
          ];
  
          sinon.stub(fs, "readFileSync");
  
          sinon.stub(files);
  
          mailSender.createAttachmentsForMail(files);
  
          sinon.assert.calledOnce(files.forEach);
  
          fs.readFileSync.restore();
          files.forEach.restore();
      });
  });
  </code></pre>