forked from mxriverlynn/jasmine.async
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Derick Bailey
committed
Aug 18, 2012
1 parent
0a3bc92
commit b776091
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Jasmine.Async, v0.1.0 | ||
// Copyright (c)2012 Muted Solutions, LLC. All Rights Reserved. | ||
// Distributed under MIT license | ||
// http://github.com/derickbailey/jasmine.async | ||
this.AsyncSpec = (function(global){ | ||
|
||
// Private Methods | ||
// --------------- | ||
|
||
function runAsync(block){ | ||
return function(){ | ||
var done = false; | ||
var complete = function(){ done = true; }; | ||
|
||
runs(function(){ | ||
block(complete); | ||
}); | ||
|
||
waitsFor(function(){ | ||
return done; | ||
}); | ||
}; | ||
} | ||
|
||
// Constructor Function | ||
// -------------------- | ||
|
||
function AsyncSpec(spec){ | ||
this.spec = spec; | ||
} | ||
|
||
// Public API | ||
// ---------- | ||
|
||
AsyncSpec.prototype.beforeEach = function(block){ | ||
this.spec.beforeEach(runAsync(block)); | ||
}; | ||
|
||
AsyncSpec.prototype.afterEach = function(block){ | ||
this.spec.afterEach(runAsync(block)); | ||
}; | ||
|
||
AsyncSpec.prototype.it = function(description, block){ | ||
// For some reason, `it` is not attached to the current | ||
// test suite, so it has to be called from the global | ||
// context. | ||
global.it(description, runAsync(block)); | ||
}; | ||
|
||
return AsyncSpec; | ||
})(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Jasmine.Async, v0.1.0 | ||
// Copyright (c)2012 Muted Solutions, LLC. All Rights Reserved. | ||
// Distributed under MIT license | ||
// http://github.com/derickbailey/jasmine.async | ||
this.AsyncSpec=function(a){function b(a){return function(){var b=!1,c=function(){b=!0};runs(function(){a(c)}),waitsFor(function(){return b})}}function c(a){this.spec=a}return c.prototype.beforeEach=function(a){this.spec.beforeEach(b(a))},c.prototype.afterEach=function(a){this.spec.afterEach(b(a))},c.prototype.it=function(c,d){a.it(c,b(d))},c}(this); |