diff spec/util_promise_spec.lua @ 11947:073e53b72792

util.promise: Support delayed promise execution
author Kim Alvefur <zash@zash.se>
date Sat, 05 Jan 2019 07:08:24 +0100
parents f3aee8a825cc
children 6d9e3f541830
line wrap: on
line diff
--- a/spec/util_promise_spec.lua	Fri Nov 26 11:40:48 2021 +0100
+++ b/spec/util_promise_spec.lua	Sat Jan 05 07:08:24 2019 +0100
@@ -668,4 +668,18 @@
 			assert.spy(on_rejected).was_called_with(test_error);
 		end);
 	end);
+	describe("set_nexttick()", function ()
+		it("works", function ()
+			local next_tick = spy.new(function (f)
+				f();
+			end)
+			local cb = spy.new();
+			promise.set_nexttick(next_tick);
+			promise.new(function (y, _)
+				y("okay");
+			end):next(cb);
+			assert.spy(next_tick).was.called();
+			assert.spy(cb).was.called_with("okay");
+		end);
+	end)
 end);