# HG changeset patch # User Matthew Wild # Date 1569828150 -3600 # Node ID da9f21a70e527a5facb3deaaa6669bf021788c44 # Parent 7072569044d4421dbc0f18d75a792fdf23d8ee06 util.promise: Add some additional tests to cover callback return values diff -r 7072569044d4 -r da9f21a70e52 spec/util_promise_spec.lua --- 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 ()