Software /
code /
prosody
Diff
spec/util_promise_spec.lua @ 10297:da9f21a70e52
util.promise: Add some additional tests to cover callback return values
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 30 Sep 2019 08:22:30 +0100 |
parent | 9557:d7fdd418adf8 |
child | 10922:7d3dbb9eb3eb |
line wrap: on
line diff
--- a/spec/util_promise_spec.lua Sun Sep 29 23:50:34 2019 +0200 +++ b/spec/util_promise_spec.lua Mon Sep 30 08:22:30 2019 +0100 @@ -248,6 +248,30 @@ assert.spy(cb3).was_called(1); assert.spy(cb3).was_called_with("goodbye"); end); + + it("ordinary values", function () + local p = promise.resolve() + local cb = spy.new(function () + return "hello" + end); + local cb2 = spy.new(function () end); + p:next(cb):next(cb2); + assert.spy(cb).was_called(1); + assert.spy(cb2).was_called(1); + assert.spy(cb2).was_called_with("hello"); + end); + + it("nil", function () + local p = promise.resolve() + local cb = spy.new(function () + return + end); + local cb2 = spy.new(function () end); + p:next(cb):next(cb2); + assert.spy(cb).was_called(1); + assert.spy(cb2).was_called(1); + assert.spy(cb2).was_called_with(nil); + end); end); describe("race()", function ()