Skip to content

Commit

Permalink
Merge pull request #296 from rock-core/dependencies-on-validate-state…
Browse files Browse the repository at this point in the history
…-machine

chore: add unit test for transitioning with a child state event on validate state machine
  • Loading branch information
jhonasiv authored Oct 23, 2024
2 parents 3675585 + c92ee59 commit 0a85e9d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/test/test_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,32 @@ module Test
assert_equal 2, current_state_task.id
end
end

it "validates transitions caused by a child state" do
@interface.describe("complex transition")
@interface.action_state_machine "with_complex_transition" do
s0 = state(some_action(id: 1))
s1 = state(some_action(id: 2))
s0.depends_on s1, role: "transition_trigger"
start s0

s2 = state(some_action(id: 3))
transition s0, s1.success_event, s2
end

test = self
validate_state_machine(
@interface.new(plan).with_complex_transition
) do
assert_transitions_to_state "s2" do |task|
test.assert_equal 1, task.id
execute { task.start! }
s1_task = toplevel_task.transition_trigger_child
execute { s1_task.start! }
execute { s1_task.success_event.emit }
end
end
end
end
end

Expand Down

0 comments on commit 0a85e9d

Please sign in to comment.