2

I have: code snippet like this:

Utils.calculate(data).then(
  function(data) { alert('success'); },
  function(data) { alert('error'); }
);

Problem: Neither 'seccess' nor 'error' are called.

Question: What I should to check?

P.S. I launch those code snippet with jasmine. So its probably that then callback have no time to run. So I decided ti set 1 second timeout at the end of my test - no result.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
VB_
  • 45,112
  • 42
  • 145
  • 293
  • Maybe `calculate` takes longer than you anticipated? What does it do? Of course it's also possible that it returns a forever-pending promise (bug? feature?). – Bergi Jul 22 '14 at 14:58
  • @Bergi no, in real app it works about few milliseconds – VB_ Jul 22 '14 at 15:01
  • @Bergi ok, so how to check that? I mean in console `Utils.calculate(data)` returns me a promise with `_status=undefined`. I don't know whether it's good or bad – VB_ Jul 22 '14 at 15:02
  • So, what's the difference between your real and test setup? Of course it should create an initially pending promise, you use them because they're asynchronous. – Bergi Jul 22 '14 at 15:03
  • Are those actual `alert` calls in your test, or some jasmine functions that are *reported* to be never called? – Bergi Jul 22 '14 at 15:03
  • @Bergi does it matter? I put a breakpoints inside `then()` callback. They are never called – VB_ Jul 22 '14 at 15:05
  • @Bergi look pls at http://stackoverflow.com/questions/24890816/jasmine-test-promises-howto. Maybe the problem is that jasmine ignores setTimeout? – VB_ Jul 22 '14 at 15:06
  • I don't think it *ignores* it, it just doesn't know of it. – Bergi Jul 22 '14 at 15:10

0 Answers0