Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Spec for asynchronous calls using jasmine's wait and waitFor

  • Loading branch information...
commit fe829acdd8bc22cfa1e0fbde1e315131379ce61d 1 parent 311fda1
Marcin Bunsch authored June 03, 2011

Showing 1 changed file with 37 additions and 0 deletions. Show diff stats Hide diff stats

  1. 37  spec/async_spec.js
37  spec/async_spec.js
... ...
@@ -0,0 +1,37 @@
  1
+describe('Jessie', function() {
  2
+
  3
+  it('should be able to handle async specs using waits', function() {
  4
+    var func = jasmine.createSpy()
  5
+
  6
+    setTimeout(func, 10)
  7
+
  8
+    setTimeout(function() {
  9
+      func.should_have_been_called()
  10
+    }, 10)
  11
+
  12
+    waits(10)
  13
+
  14
+  })
  15
+
  16
+  it('should be able to handle async specs using waitsFor', function() {
  17
+    var func = jasmine.createSpy()
  18
+    var a = 0
  19
+
  20
+    setTimeout(function() {
  21
+      func()
  22
+      a = 1
  23
+    }, 10)
  24
+
  25
+    waitsFor(function() {
  26
+      if (a == 1) {
  27
+        func.should_have_been_called()
  28
+        return true
  29
+      } else {
  30
+        return false
  31
+      }
  32
+    }, 10, 'result')
  33
+
  34
+  })
  35
+
  36
+
  37
+})

0 notes on commit fe829ac

Please sign in to comment.
Something went wrong with that request. Please try again.