vendredi 8 juillet 2016

Testing anonymous function

Trying to write a unit test for the following code:

if ($rootScope.associates == null) {
      Papa.parse('file', {
        download: true,
        header: true,
        dynamicTyping: true,
        complete: function(results, file) { //TRYING TO TEST THIS
          $rootScope.associates = results;
        }
      });
    }

I have tested everything except for the anonymous function complete.

My test case:

it('should test papa.parse', function() {
      spyOn(Papa, "parse");
      Papa.parse("file");
      expect(Papa.parse).toHaveBeenCalled();
      expect(Papa.parse).toHaveBeenCalledWith("file");
      expect(rootScope.associates).toBe(null);
    });

Any suggestions? Thanks :)

Aucun commentaire:

Enregistrer un commentaire