javascript - $q doesn't remove pending tasks in angular -
if create test angular use $q mock or create promise defer task created.
i thought calling $rootscope.$apply should resolve these promises.
but if call $timeout.verifynopendingtasks() exception thrown because
error: deferred tasks flush (1): {id: 0, time: 0}
why , how fix ?
it.only('should work', function () { var spy = sinon.spy(); $q.when().then(spy); $rootscope.$apply(); spy.should.have.been.called; $timeout.verifynopendingtasks(); });
Comments
Post a Comment