Timeout not working in AngularJS Karma program - Jasmine
My code:
describe('Popup', function(){
it("Should close on second click", function(){
compileDirective(400,'click','true');
element.triggerHandler('click');
timeout(function() {
element.triggerHandler('click');
scope.$digest();
timeout.flush();
element.remove();
$(".sidepopright").remove();
}, 1000);
});
});
I want to make a delay for the second click of the popup, so I will timeout after the first click. However, this doesn't work. Anyone have an idea?
+3
user2991183
source
to share
2 answers
You should be using the $ timeout injecting service , not the timeout.
$timeout(function () {
// Do something
}, 1000);
0
jmgem
source
to share
You must use $ timeout.flush (); to simulate timeout completion in unit test.
0
MrWiLofDoom
source
to share