Browse Source

d2 ex

master
Ganesh 5 years ago
parent
commit
98e3c52833
3 changed files with 31 additions and 3 deletions
  1. 5
      jasmine-async-await/unit-tests/js-3.6.0/SpecRunner.html
  2. 27
      jasmine-async-await/unit-tests/js-3.6.0/spec/MockClockSpec.js
  3. 2
      jasmine-async-await/unit-tests/js-3.6.0/spec/PromisesAndCallbacksSpec.js

5
jasmine-async-await/unit-tests/js-3.6.0/SpecRunner.html

@ -19,8 +19,9 @@
<!-- include spec files here... -->
<!--script src="spec/SpecHelper.js"></script>
<script src="spec/PlayerSpec.js"></script-->
<script src="spec/sampleSpec.js"></script>
<script src="spec/PromisesAndCallbacksSpec.js"></script>
<!--script src="spec/sampleSpec.js"></script>
<script src="spec/PromisesAndCallbacksSpec.js"></script-->
<script src="spec/MockClockSpec.js"></script>
</head>

27
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
});
});

2
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()

Loading…
Cancel
Save