javascript - Angular promises fail to resolve in all subsequent unit tests (ngMock) -


we've upgraded angular 1.5-rc0. 1 recent change ngmocks destroys $rootscope after every test. however, i'm struggling figure out why promises use inside our app never fire after first time.

here's test simulates right-click event test context menu directive. directive uses utility load html template, cache it, etc. service resolves promise when template loaded.

however, angular/ngmock 1.5, promise resolves first "it" block. $rootscope should re-created every test don't understand what's holding up.

describe('context-menu directive', function() {     beforeeach(function() {         module('templates', 'contextmenu');          inject(function(_$compile_, _$rootscope_) {             var scope = _$rootscope_.$new();             scope.choices = [{                 text: 'test',                 handler: function() {}             }];              $template = _$compile_('<div context-menu="choices"></div>')(scope);         });     });      it('compiles without choices', function() {      });      it('right click triggers menu', function() {         helpers.rightclick($template);         // event triggers template load , resolve promise         // however, promise fires if previous "it" block removed          $menu = $('.context-menu');         console.log($menu.length);     }); }); 

i've tried manually calling $rootscope.$apply() force promise resolution doesn't here.

here's important bit of our template helper resolves promise:

var deferred = $q.defer();  // check cache var template = $templatecache.get(templateurl); if (template) {     deferred.resolve(template); } 

i've verified deferred.resolve called, then listeners never do.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -