|
|
|
@ -0,0 +1,27 @@ |
|
|
|
describe('debounced test', function(){ |
|
|
|
|
|
|
|
beforeEach(function(){ |
|
|
|
jasmine.clock().install(); |
|
|
|
}); |
|
|
|
|
|
|
|
afterEach(function(){ |
|
|
|
jasmine.clock().uninstall(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should call the method only after the 500ms debounce', function(){ |
|
|
|
function debouncedMethod() { |
|
|
|
// do something async;
|
|
|
|
} |
|
|
|
|
|
|
|
function evaluateResults() { |
|
|
|
// check results of async function
|
|
|
|
} |
|
|
|
debouncedMethod(); |
|
|
|
|
|
|
|
jasmine.clock().tick(501); //increment clock 501 ms.
|
|
|
|
|
|
|
|
evaluateResults(); |
|
|
|
|
|
|
|
//assertions follow
|
|
|
|
}); |
|
|
|
}); |