Promise.js 778 B

12345678910111213141516171819202122232425262728293031323334
  1. describe('Promise', function() {
  2. var Promise = $.fullCalendar.Promise
  3. describe('when result given at instantiation', function() {
  4. it('executes the then function immediately', function() {
  5. var p = Promise.resolve(7)
  6. var executedThen = false
  7. p.then(function(val) {
  8. executedThen = true
  9. expect(val).toBe(7)
  10. })
  11. expect(executedThen).toBe(true)
  12. })
  13. it('forwards on the result of the then function', function() {
  14. var p = Promise.resolve(7)
  15. var executedSecondThen = false
  16. p.then(function(val) {
  17. expect(val).toBe(7)
  18. return 8
  19. }).then(function(val) {
  20. expect(val).toBe(8)
  21. executedSecondThen = true
  22. })
  23. expect(executedSecondThen).toBe(true)
  24. })
  25. })
  26. })