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>