Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我的ng blur调用可以正常运行,但却赢得了';你不能通过单元测试吗?茉莉花_Javascript_Html_Angularjs_Unit Testing_Jasmine - Fatal编程技术网

Javascript 为什么我的ng blur调用可以正常运行,但却赢得了';你不能通过单元测试吗?茉莉花

Javascript 为什么我的ng blur调用可以正常运行,但却赢得了';你不能通过单元测试吗?茉莉花,javascript,html,angularjs,unit-testing,jasmine,Javascript,Html,Angularjs,Unit Testing,Jasmine,我在服务器上测试了我的代码,当我使文本框模糊时,它将正确调用pinNameEditBlur,但它不会通过这里的单元测试。单元测试的错误是pinNameEditBlur未调用。我不知道这是否是因为我用了错误的方法来模拟blur() HTML: 测试错误: Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/11.12.0 PinTable ng-blur should call function pinNameEditB

我在服务器上测试了我的代码,当我使文本框模糊时,它将正确调用
pinNameEditBlur
,但它不会通过这里的单元测试。单元测试的错误是
pinNameEditBlur
未调用。我不知道这是否是因为我用了错误的方法来模拟
blur()

HTML:

测试错误:

Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/11.12.0 PinTable ng-blur should call function pinNameEditBlur when the text box is blurred FAILED
        Error: Expected spy pinNameEditBlur to have been called.
            at <Jasmine>
            at UserContext.<anonymous> (src/test/karma/specs/PinTable.spec.js:276:41)
            at <Jasmine>
Mozilla/5.0(win32)AppleWebKit/537.36(KHTML,如Gecko)jsdom/11.12.0当文本框模糊失败时,PinTable ng blur应调用函数pinNameEditBlur
错误:应已调用spy pinNameEditBlur。
在
在UserContext。(src/test/karma/specs/PinTable.spec.js:276:41)
在
describe("ng-blur", function(){
      it("should call function pinNameEditBlur when the text box is blurred", function(){
          var element = document.createElement('div');
          document.getElementById = jasmine.createSpy('HTML Element').and.returnValue(element);
          var elementId = "edit-pin-name-text-2";
          spyOn(scope, 'pinNameEditBlur');
          document.getElementById(elementId).blur();
          expect(element.classList.contains('blur'));
          expect(scope.pinNameEditBlur).toHaveBeenCalled();
});
Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/11.12.0 PinTable ng-blur should call function pinNameEditBlur when the text box is blurred FAILED
        Error: Expected spy pinNameEditBlur to have been called.
            at <Jasmine>
            at UserContext.<anonymous> (src/test/karma/specs/PinTable.spec.js:276:41)
            at <Jasmine>