Skip to content

Commit

Permalink
Added example test showing promises are imported with rooibos tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdp committed Jan 15, 2025
1 parent 41516f4 commit 9950c80
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/src/source/Promises.spec.bs
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

0 comments on commit 9950c80

Please sign in to comment.