test/callbacks.rb in micromachine-2.1.0 vs test/callbacks.rb in micromachine-3.0.0
- old
+ new
@@ -40,5 +40,20 @@
machine.trigger(:confirm)
assert_equal(:confirm, event_name)
end
+
+test "passing the payload from transition to the callbacks" do
+ received_payload = nil
+
+ machine = MicroMachine.new(:pending)
+ machine.when(:confirm, pending: :confirmed)
+
+ machine.on(:confirmed) do |_event, payload|
+ received_payload = payload
+ end
+
+ machine.trigger(:confirm, foo: :bar)
+
+ assert_equal({ foo: :bar }, received_payload)
+end