Skip to content

Commit

Permalink
Add failing test for missing default
Browse files Browse the repository at this point in the history
  • Loading branch information
ekosz committed Oct 2, 2024
1 parent 8b4f956 commit 687cd85
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/reactor/dsl/switch_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,30 @@ defmodule Reactor.Dsl.SwitchTest do
return :is_truthy?
end

defmodule SwitchNoDefaultReactor do
@moduledoc false
use Reactor

input :value

switch :is_nil? do
on input(:value)

matches? &is_nil/1 do
step :falsy, Noop
end
end
end

test "when provided a falsy value it works" do
assert {:ok, :falsy} = Reactor.run(SwitchReactor, value: nil)
end

test "when provided a truthy value it works" do
assert {:ok, :truthy} = Reactor.run(SwitchReactor, value: :marty)
end

test "it does not require a default" do
assert {:ok, nil} = Reactor.run(SwitchNoDefaultReactor, value: nil)
end
end

0 comments on commit 687cd85

Please sign in to comment.