测试匿名函数

时间:2016-07-08 14:38:32

标签: angularjs unit-testing jasmine

尝试为以下代码编写单元测试:

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

我测试了除匿名函数complete以外的所有内容。

我的测试用例:

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);
    });

有什么建议吗?谢谢:))

0 个答案:

没有答案
相关问题