-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added example test showing promises are imported with rooibos tests
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace tests | ||
@async(1000) | ||
@SGNode("NodeExample") | ||
@suite | ||
class NodePromisesTests extends rooibos.BaseTestSuite | ||
|
||
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
@describe("rooibos.promises.chain()") | ||
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
@async | ||
@it("example using rooibos.promise.chain") | ||
sub _() | ||
context = { | ||
thenCount: 0 | ||
catchCount: 0 | ||
finallyCount: 0 | ||
} | ||
|
||
rooibos.promises.chain(rooibos.promises.resolve(1), context).then(sub(result, context) | ||
context.thenCount++ | ||
m.testSuite.assertEqual(result, 1) | ||
end sub).catch(sub(error, context) | ||
context.catchCount++ | ||
m.testSuite.fail("should not get here") | ||
end sub).finally(sub(context) | ||
context.finallyCount++ | ||
m.testSuite.assertEqual(context, { | ||
thenCount: 1 | ||
catchCount: 0 | ||
finallyCount: 1 | ||
}) | ||
m.testSuite.done() | ||
end sub) | ||
end sub | ||
end class | ||
end namespace |