From 98e3c5283392317992b6c173d23a43a9cb437d0e Mon Sep 17 00:00:00 2001 From: Ganesh Date: Tue, 20 Oct 2020 19:22:52 +0530 Subject: [PATCH] d2 ex --- .../unit-tests/js-3.6.0/SpecRunner.html | 5 ++-- .../unit-tests/js-3.6.0/spec/MockClockSpec.js | 27 +++++++++++++++++++ .../js-3.6.0/spec/PromisesAndCallbacksSpec.js | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100755 jasmine-async-await/unit-tests/js-3.6.0/spec/MockClockSpec.js diff --git a/jasmine-async-await/unit-tests/js-3.6.0/SpecRunner.html b/jasmine-async-await/unit-tests/js-3.6.0/SpecRunner.html index 6cd70b6..24d9731 100644 --- a/jasmine-async-await/unit-tests/js-3.6.0/SpecRunner.html +++ b/jasmine-async-await/unit-tests/js-3.6.0/SpecRunner.html @@ -19,8 +19,9 @@ - - + + diff --git a/jasmine-async-await/unit-tests/js-3.6.0/spec/MockClockSpec.js b/jasmine-async-await/unit-tests/js-3.6.0/spec/MockClockSpec.js new file mode 100755 index 0000000..64e6fd5 --- /dev/null +++ b/jasmine-async-await/unit-tests/js-3.6.0/spec/MockClockSpec.js @@ -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 + }); +}); \ No newline at end of file diff --git a/jasmine-async-await/unit-tests/js-3.6.0/spec/PromisesAndCallbacksSpec.js b/jasmine-async-await/unit-tests/js-3.6.0/spec/PromisesAndCallbacksSpec.js index b487acf..909198b 100755 --- a/jasmine-async-await/unit-tests/js-3.6.0/spec/PromisesAndCallbacksSpec.js +++ b/jasmine-async-await/unit-tests/js-3.6.0/spec/PromisesAndCallbacksSpec.js @@ -99,7 +99,7 @@ describe('Promise', () => { it('you must return a rejected promise if you want to execute the next fail callback', (done) => { function someApiCall() { - return Promise.reject('Error'); + return Promise.reject('Backend System is down'); } someApiCall()