javascript - Angular.js unit test "inject()" fires before a "run" phase block -


I have a scenario where I am trying to load the HTML5 audio for mobile devices and this is only for user interaction Can be obtained through the medium (eg ontouchstart). I have implemented this argument in an angular move, because it is to be sure that it is first engage on the spot. I can not attach it to the config phase because it is dependent on factories of other fingers:

  Angular Module ('MyModule'). ([ 'Device', 'resource manager' exception Factoretik ', function (device, resource manager, exceptions Factory) {if device! Brosr. Ficharskvebudio) {var Prfrst user interaction = function () {var sound = Resources The Manager. Gatesounds (); If (sounds.length & gt; 1) {ExceptionFactory .create ( 'Html5AudioLimitReachedException', 'Html5 audio device can only load a sound resource');} if (sounds.length === 1) {sounds [0] .createBrowserAudioObject ();} document.documentElement.removeEventListener (device. Browser.is.IE? 'click' 'Tcstart' first user interaction, true);}; Document.documentElement.addEventListener (Click 'Device.browser.is.IE?': 'TouchStart', First User Interaction, true);}}]));   

I have failed the following unit test because the above event handler is not registered at the time:

  first (each function () {angular.module ( 'Html5SoundLoaderApp', []) Krun ([ "device", "resource Manager" function (tool, resource Manager) {Device.browser.features.webaudio = false; ResourceManager.addSound ( 'testOne', 'test / url / TestOne.mp3, {}); resource manager.addons ('test to', 'test / url / testtivo.mp3', {});})); Module ('HTML5 Sound Laider App');}); This ( 'should only be able to load a sound resource ", (to inject ([' exception Factori ', function (Apwadfainr)) {var spy = sinon.spy (exceptions make Factoretik,' '); (hopefully work () (Angulrkmock Uiktrigr (Dokyumentkdokyumentelement "Toucstrt ')}). Tokthro (); Spaikshudkhvekbinkkalledonke; Spaikshudkhvekbinkcoledvith (' Html5AudioLimitReachedException ' , 'HTML5 audio devices can only load a sound resource');}]);   

I expected that the run (block) was completed before the start of the test Will go? Or am I wrong in this belief? If so, how would it be best to deal with this situation?

Thanks

That code seems to me as an asynchronous (because it is waiting for one user interaction for one thing), so done () callback:

  first (work) {//   

For any purpose you have to use done () which is executed asynchronously, otherwise Mokha will proceed without waiting for the display .

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -