angularjs - ng-blur in Karma on Firefox -
Karma for an Angular.js instruction. In the JS unit test, face strange oddities in the behavior between Chrome and Firefox Had it
The director has a template, and this template contains a form with some input. I want to test the unit that there will be some scope methods called after the input first.
Then, I have this test:
Description ('Firefox quibble.' (Function) () (module ('template'); module ('app') ; Injection (function $ collection, $ rootsecope) {$ scope = $ rootScope. $ New (compiled) $ compile (template) ($ radius); angular.imment (compiled) .appendTo (document.body); $ scope . $ Apply);}};}); ('Iirdness Shows.', Function () {var i1 = compiled.find ('input [name = "i1"]'), i2 = compiled.find ('input [name = "I2"]'), executed = Incorrect; // This is never called on Firefox. // It works on Chrome without any delay. $ Scope.doStuff = function () {execed = true;}; // First focus the input, So the second. // If I delay them through the settings, // do not help to digest the scope. Angular.el ement (i1) .focus (); angular.element (i2) .focus () ; // This line fails (Execute) .to.be.true;}); });
More instructions look like this (this is Z):
form (name = "form") input (name = "i1", ng) - Blur = "doStuff ()") input (name = "i2")
While my JS code is:
Description ('Firefox weirdness. ', Function () {var app = angular.module (' app ', []); app.controller (' MainCtrl ', function ($ radius) {$ scope.doStuff = function () {console.log (' content The complete ('' e '' template templates: 'dir.html'};});
P> What's wrong? The exam passes on Chrome, but in Firefox - this fails I have some time limit Trying to use this etc. to govern some time issues, but it will still fail. To fix this? I used Angular.js 1.2, Mocha + Chai and Karma- Use the ng-jade2js-preprocessor as a separate angler module (for testing, avoid trying to load them asynchronous).
I have given a brief example in this repo: Cloning it, installing NPM dependencies and ./r Try it out by running start karma.conf
. As a result, you will see passing the Chrome exam, and Firefox will be a failure.
You can actually trigger the event instead of blurring
Angular Element (i1). Focus ();
Perhaps triggering the focus event on any other input does not trigger the blurred event of the first focused input in Firefox
If you forget about the glass If it is gone, then it will also fail.
This (shows 'weirdness.', Function () {var i1 = compiled.find ('input [name = "i1"]' ), I2 = compiled.find ('input [name = "i2"]'), executed = false; angular element (i1) .bind ('blurred', function () {executed = true;}); angular Element (i1) .fO Fertility (Execute) .to.be.true;});
While this is not
('odd displays.', Function () {var i1 = compiled.find ('input [name = I1 "] ', i2 = compiled.find (' input [name =" i2 "] '), executed = false; angular element (i1) .bind (' blur ', function () {execute = true;} ); Angular element (i1) .blur (); hope (executed) .to.be.true;});
Comments
Post a Comment