dimanche 24 juillet 2016

Asserting that a method from a for loop object is called

I have the below method for which I need to write unit test. I need to verify that the onProductScanCallback was called on productScanCallback object. But how can I assert this as I cannot spy on the object using sinon as the object is available only within the for loop? Any help would be much appreciated.

 for (var i in receivedData) {
 if (receivedMessage.data.eventId === 'RFIDScanned' || that.regexProductScan.test(receivedData[i].data)) {
        for (var productScanCallback of that.onProductScanCallbacks) {
          productScanCallback.onProductScanCallback(receivedData[i].data);
        }
      }
  }

Aucun commentaire:

Enregistrer un commentaire